cs-icon.svg

Transform

The Transform action connector helps in manipulating texts and numbers as required. It helps you to manipulate and structure data according to our needs.
For example, suppose in the previous trigger specific data is selected to be displayed. In that case, the action defined by the Transform connector can manipulate or change it to meet your display requirements.

Set Up the Transform modifiers

Perform the following steps to set up the Transform action connector:

  1. Click Configure Action Step from the left navigation panel.
  2. Click Action Step to configure third-party services.
  3. Within the Configure Action Step, click the Transform connector.
    Transform.png
  4. Under Choose an Action tab, select the Transform action.
    Transform_Action
  5. On the Configure Action page, enter the following details:
    1. Click the Add Input button, and enter a variable name for the Input Name (say, “name”) and an Input Value for the variable (say, “john” in lowercase letters).

      Note: You can even pass the value directly into the Transformation box.

    2. Let’s enter the JSON code that uses the “capitalize()” modifier in the Transformation box. Use the following code: {“result” : “{capitalize(name)}” }
      Transform_Configure_Action
  6. Click Proceed.
  7. You will see the input values which you have configured in the Configure Action modal.
    Transform_Action_Input
  8. Check if the details are correct. If yes, click Test Action.
    Transform_Action_Test_Action
  9. Once set, click Save and Exit.
    Transform_Action_Output

This sets up the Transform action connector.

Transform Modifiers

Transform modifiers help in manipulating texts and numbers as per our needs. This function utilizes JSON code and modifiers to transform data.
The Transform connector also helps in mapping different JSON objects into one object, as seen in the sample transform input data:

{
  "first_name" : "{user_first}",
  "last_name" : "{user_last}",
  "full_name" : "{join(user_first,user_last,' ')}",
  "country" : "india",
  "time" : "{now('toISO')}"
}

The Transform function has specific modifiers that can manipulate the data. Let’s look at the applicable transform modifiers in detail.

truncate

Use this modifier to reduce the length of a string to a specific number of characters or words using ellipses or word-break options.

Note: The boolean value (true, false) implies whether you want to break the word or not. True means you want to break the word, and false means not. The space after the word is considered a break.

Example: truncate (string,number of characters,'ending string', ‘word break’)

Note: If the limit for the number of characters is more than that of the string, the output will contain the complete string without ellipses.

Here’s a screenshot that shows the input:

Truncate_Input

Here’s a screenshot that shows the output:

Truncate_Output

Here’s a screenshot that shows the input when the word break is set to true by default.

True_Work_Break

Here’s a screenshot that shows the output:

True_Work_Break_Output

Note: In the truncate modifier, string and the number of characters are the two mandatory fields. If we do not specify the ending string, it would take the ellipses (...) or any other characters the user enters such as (***).

Here’s a screenshot that shows the input when the limit for the number of characters is greater than that of the string irrespective of the work break value(true/false).

Limit_On_the_Character

Here’s a screenshot that shows the output:

Limit_of_the_Characters_Output

replace

Use this modifier to replace any character, word, or string given in the 2nd argument with the 3rd argument.
Example: replace(data, 'one char, one word or string', 'with this string')

Note: The replace modifier can only replace the first occurrence of a character/word/string.

Here’s a screenshot that shows the input:

Replace_Input

Here’s a screenshot that shows the output:

Replace_Output

You can also pass the data configured from the previous step and replace the content. Here is an example:

  1. Configure your HTTP Trigger and use the trigger data in the input value field.
    Replace_Dynamic_Input
  2. To replace the word Hello with Hi.
    Replace_Hello_With_Hi

    Here’s a screenshot that shows the output:

    Replace_Dynamic_Output

replaceAll

Use this modifier to replace all the characters, words, or strings given in the 2nd argument with the 3rd argument.
Example: replaceAll(data, 'one char, one word or string', 'with this string')

Note: The replaceAll modifier will replace multiple occurrences of a character/word/string with the same pattern.

Here’s a screenshot that shows the input:

ReplaceAll_Input

Here’s a screenshot that shows the output:

ReplaceAll_Output

You can also pass the data configured from the previous step and replace the content. Here is an example:

  1. Configure your HTTP Trigger and use the trigger data in the input value field.
    ReplaceAll_Dynamic_Input
  2. To replace all the occurrences of the word hello with hi.
    ReplaceAll_Dynamic_Input_Transformationbox

    Here’s a screenshot that shows the output:

    ReplaceAll_Dynamic_Output

    trim

    Use this modifier to remove white spaces at the beginning and end of the string, including tab, space, null byte, new line, and carriage return.
    Example: trim(data)

    Here’s a screenshot that shows the input:

    Trim_Iutput

    Here’s a screenshot that shows the output:

    Trim_Output

    capitalize

    Use this modifier to convert the input data into the capital (upper) case.
    Example: capitalize('input data') or capitalize(variable)

    Here’s a screenshot that shows the output:

    Transform_Modifier_Capitalize

    camelCase

    Use this modifier to convert the input text into the camel case.
    Example: camelCase('input data')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Camelcase

    kebabCase

    Use this modifier to convert the input text into the kebab case.
    Example: kebabCase('input data')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Kebabcase

    snakeCase

    Use this modifier to convert the input text into the snake case.
    Example: snakeCase('input data')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Snakecase

    escape

    Use this modifier to escape HTML characters.
    Example: escape('<data input>')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Escape

    split

    Use this modifier to split the text into an array.
    Example: split('data-input' , '-')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Split

    join

    Use this modifier to join all items of an array to make a single string.
    Example: join(…arrayRef|string , '-')

    Here’s a screenshot that shows the input:

    Transform_Join_Input

    Here’s a screenshot that shows the output:

    Transform_Join_Output

    number

    Use this modifier to convert text into numbers.
    Example: number('3')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Number

    sum

    Use this modifier to perform the addition of all numbers.
    Example: sum(5,10,2)

    Here’s a screenshot that shows the output:

    Transform_Modifier_Sum

    random

    Use this modifier to generate random numbers from a specified range.
    Example: random(1, 50)

    Here’s a screenshot that shows the output:

    Transform_Modifier_Random

    max

    Use this modifier to retrieve the largest number from an array.
    Example:max(arrayRef)

    Here’s a screenshot that shows the input:

    Transform_Max_Inpt

    Here’s a screenshot that shows the output:

    Transform_Max_Output

    min

    Use this modifier to retrieve the smallest number from an array.
    Example: min(arrayRef)

    Here’s a screenshot that shows the input:

    Transform_Min_Input

    Here’s a screenshot that shows the output:

    Transform_Min_Output

    upperCase

    Use this modifier to convert the input text into upper case.
    Example: upperCase('hello world')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Uppercase

    lowerCase

    Use this modifier to convert the input text into lower case.
    Example: lowerCase('Hello World')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Lowercase

    text

    Use this modifier to convert numbers to the text type, i.e., this modifier typecasts data which means that the data type gets changed to string.
    Example: text(3)

    Here’s a screenshot that shows the output:

    Transform_Modifier_Text

    uniqueItems

    Use this modifier to remove duplicate items and return unique values from an array.
    Example: uniqueItems(arrayRef)

    Transform_UniqueItems_Input

    Here’s a screenshot that shows the output:

    Transform_UniqueItems_Output

    findInCollection

    Use this modifier to return objects from an array specified in the conditions.
    Example: findInCollection(collectionRef, 'name=bob&type=author')

    Here’s a screenshot that shows the input:

    Transform_FindInCollection_Input

    Here’s a screenshot that shows the output:

    Transform_FindInCollection_Output

    filterCollection

    Use this modifier to filter an array and remove all objects which do not match the condition.
    Example: filterCollection(collectionRef, 'name=Rahul')

    Here’s a screenshot that shows the output:

    Transform_Modifier_Filter_Collection

    mapCollection

    Use this modifier to map the collection data. This function will help users create a new collection by mapping data to different keys.
    Example: { "userslist": "{mapCollection(users,'email_id=email&job=occupation')}" }

    Here’s a screenshot that shows the output:

    Transform_Modifie_Map_Collection

    size

    Use this modifier to retrieve the size of an array.
    Example: size(...arrayRef)

    Here’s a screenshot that shows the output:

    Transform_Modifier_Size

    now

    Use this modifier to retrieve the current timestamp.
    Example: now('toISO')
    Options: toISO | toDate | toGMT | toUTC | toTime

    Here’s a screenshot that shows the output:

    Transform_Modifier_Now

    uuid

    Use this modifier to retrieve the unique ID based on UUID v4.
    Example:
    uuid()
    { "uuid" : "{uuid()}"}

    Here’s a screenshot that shows the output:

    Transform_Modifier_Uuid

    Using Multiple Filters

    You can also pass data in for more than one filter, as shown below:

    {
    “name”: “{lowerCase(firstname)|upperCase($pipe)}”
    }

    Here’s a screenshot that shows the output:

    Transform_Modifier_Multiple_Filters


Was this article helpful?
^