When editing a target field in a flow, you can add a transform function to customize the value of a source field that is to be passed to the target application.

The following table lists some of the available transform functions, describes the purpose of each transform function, and gives an example.

Notes:

  • The syntax of the functions is JSONata, a lightweight query and transformation language. For example, JSONata string functions are shown in the table JSONata string functions. Learn more about JSONata functions at http://jsonata.org.
  • You can insert functions into a target field by several techniques (after selecting the target field):
    • Select a source field that you have already inserted into the target field, and then select Apply a function from the context menu; select a function from the list provided.
    • Select the Insert function icon (fx), then select a function to insert into the target field, and then insert source fields into the function.
    • Type the JSONata expression directly.
  • In the target field, a function is represented with curly brackets; for example:
    email_b4_function

    after applying the substringBefore function, becomes:

    email_with_function

  • You can edit a JSONata expression to apply more complex functions, including the use of regular expressions; for example:
    {{$substringBefore($substringAfter(name, "Name: "), ", Email:")}}

    adds John Smith to the target field if the source field contains ... Name: John Smith, Email: ....

  • If a JSONata expression is not valid, an error message is displayed below the target field; for example:
    JSONata expression: ?{{$uppercase(Department)}
    Use '}}' to end an expression
    
  • If you want to test out your JSONata expression before adding it in App Connect, you can use the JSONata Exerciser
  • provided at http://jsonata.org.

JSONata string functions
Function Description Example
contains(field) Returns true if str is matched by pattern, otherwise it returns false. The pattern parameter can either be a string or a regular expression (regex). For example:

$contains("abracadabra", "bra") => true
$contains("abracadabra", /a.*a/) => true
$contains("abracadabra", /ar.*a/) => false
length(field) Returns the number of characters in the source field. You can get the number of characters in a name. For example:

{{$length(Last Name)}}

adds 3 to the target field if the source field contains Doe.

lowercase(field) Convert the source field to lower case. You can convert a name to lower case. For example:

{{$lowercase(Last Name)}}

adds doe to the target field if the source field contains Doe.

replace(field, pattern, replacement [, limit]) Finds occurrences of pattern within the source field and replaces them with replacement. The pattern parameter can either be a string or a regular expression (regex). The replacement parameter can either be a string or a function. The optional limit parameter, is a number that specifies the maximum number of replacements to make before stopping.

For more details and examples, see the JSONata documentation

For example:

{{$replace(Name, "Jane", "Ms")}}

adds Ms Doe to the target field if the source field, Name, contains Jane Doe.


{{$replace(Name, /(\w+)\s(\w+)/, "$2, $1")}}

adds Doe, Jane to the target field if the source field, Name, contains Jane Doe.

substring(field, start[, length]) Add the substring of a source field that starts at position start (zero-offset). If length is specified, then the substring will contain the maximum length characters. If start is negative then it indicates the number of characters from the end of the source field. You can extract the first 3 characters of a name. For example:

{{$substring(Name, 0, 3)}}

adds Jan to the target field if the source field, Name, contains Jane Doe.

substringAfter(field, “string“) Add the part of a source field that occurs after a given string of characters. You can extract the mail domain from an email address, by using ‘@’ as the delimiting character. For example:

{{$substringAfter(Email, "@")}}

adds email.com to the target field if the source field, Email, contains Jane Doe@email.com.

substringBefore(field, “string“) Add the part of a source field that occurs before a given string of characters You can extract the name from an email address, by using ‘@’ as the delimiting character. For example:

{{$substringBefore(Email, "@")}}

adds Jane Doe to the target field if the source field, Email, contains Jane Doe@email.com.

trim(field) Normalizes and trims all whitespace characters in the source field by applying the following steps:

  • All tabs, carriage returns, and line feeds are replaced with spaces.
  • Contiguous sequences of spaces are reduced to a single space.
  • Trailing and leading spaces are removed.
You can trim a string field. For example:

{{$trim(Description)}}

adds Hello World to the target field if the source field, Description, contains Hello \n World .

uppercase(field) Convert the source field to upper case. You can convert a name to upper case. For example:

{{$uppercase(Last Name)}}

adds DOE to the target field if the source field, Last Name, contains Doe.

Join The Discussion

Your email address will not be published. Required fields are marked *