Help Desk

Submit a ticket My Tickets
Welcome
Login

Variable Transformation

How to Transform Variables

OneCloud can transform data to conform to the format that is needed within your chains. The following variable and data types can be used in variable transformations:

Variable Types:

Data Types:

  • String
  • Date
  • JSON

Depending on the data variable type, the following operations are supported:

OperationData TypeDescription
LowercaseStringConvert a string to lowercase
UppercaseStringConvert a string to uppercase
Parse Text as JSONStringConvert text formatted as JSON to a proper JSON output for use in subsequent OneCloud Commands
Date & Time FormatString Date/TimeFormat Date/DateTime strings
Date MathString Date/TimeAdd/subtract time units from a Date/DateTime
SortListSort a list based in ascending or descending order
Pick from ListListPick an individual element from a list. (0 for the first and -1 for the last element)
JSON ParsingJSONPick individual elements from a proper JSON text string

String Transformation

String transformation enables any variable that is of data type string to be transformed to upper or lower case as well as parsed and converted to a JSON data type. To start a transformation, select the variables and select the required transformation.

Example:

Date Transformation

Data transformation allows Date/DateTime strings to be transformed into various formats based upon strftime formatting symbols. For a comprehensive description of the format specifier, please refer to this strftime format guide. These formatting characters can then be combined with other separator characters such as the following characters: , : / . 

The following table illustrates various format strings and the corresponding format.

FormatExample
%m-%d-%Y01-30-2020
%H:%M21:08

Example:

Date Math

Date math transformations enable timestamps to be added or subtracted based upon the following parameters:

Format
ISO extended or custom date format
Operation
Add/ Subtract
Amount
Numeric value
Unit
  • Day
  • Month
  • Year
  • Hour
  • Minute

Example:

List Transformation

Lists can be sorted in ascending or descending order, and specific elements can be extracted from a list. In the example below, the first Command lists the files in a directory, and the list output from the first Command is first sorted, and then the first value of that list is extracted.

List Output

List transformation will only operate with Command outputs of the type 'List'.

Example:

JSON Transformation

Many public Rest APIs provide responses in a JSON format. The data in the response can be transformed and used within your chain. There are a few simple things to remember when using JSON transformations: 

  1. Elements in a list within JSON use zero-based indexing (this first element is at the zero index)
  2. Reference the element name on the left
  3. Match the element type (string, list, or JSON)

Example:

[{
	"email": "demo@onecloud.io",
	"decision": "rejected",
	"decidedAt": "2019-01-13T22:59:52.018377",
	"comment": "Please review again"
}, {
	"email": "demo@onecloud.io",
	"decision": "approved",
	"decidedAt": "2020-01-13T22:59:52.018377",
	"comment": "Looks great!"
}]

The example JSON above is a response from OneCloud Human Integration Workflow. If the second decision element is in the list to be selected, then a transformation would be added as follows:

  1. Add a variable transformation on a variable that holds JSON (see example JSON above).
  2. Add the first transformation `Parse Text as JSON`
  3. Add the second transformation `Get Value from JSON` and select the elements in the array.

Results:



What's Next?

Learn about Trigger Events.

B
Brian is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.