Skip to main content

Helper Functions

Helper functions enhance the customization of workflow modules such as API Request, Dynamic Form, Validator, and Custom Response. These functions enable the pre-filling of values, increasing the flexibility and efficiency of workflows.

By utilizing these helper functions, workflows can be easily customized to meet specific requirements, minimizing manual effort and simplifying configuration. They are particularly useful for managing custom claims, transforming data, and preparing requests in a seamless and automated manner.

With helper functions, workflows become highly dynamic and adaptable, allowing for smooth data transformation and effortless customization to accommodate a wide range of use cases.

Available Functions

1 GenerateUUID

The function (${GenerateUUID}) generates a universally unique identifier (UUID).

  • Example Usage:
    {  
    "id": "${GenerateUUID}"
    }
  • Expected Output:
    {  
    "id": "550e8400-e29b-41d4-a716-446655440000"
    }

2 Replace

The function ${Replace(${value}, {value1: newvalue1, value2: newvalue2})} maps specific input values to corresponding replacements.

  • Example Usage:
    {  
    "gender_value": "${Replace(${env.gender}, {M: 1, F: 2})}"
    }
  • Expected Output:
    {  
    "gender_value": "2" // If the gender value is 'F', it will be replaced with '2'.
    }

3 Date

The function ${Date(${env.dob}, dd-MM-yyyy)} formats a given date into a specific pattern.

  • Example Usage:
    {  
    "dob_formatted": "${Date(${env.dob}, dd-MM-yyyy)}"
    }
  • Expected Output:
    {  
    "dob_formatted": "29-01-1999"
    }

4 ToLowerCase

The function ${ToLowerCase(${env.last_name})} converts a string to lowercase.

  • Example Usage:
    {  
    "last_name_lowercase": "${ToLowerCase(${env.last_name})}"
    }
  • Expected Output:
    {  
    "last_name_lowercase": "doe"
    }

5 ToUpperCase

The function ${ToUpperCase(${env.first_name})} converts a string to uppercase.

  • Example Usage:
    {  
    "first_name_uppercase": "${ToUpperCase(${env.first_name})}"
    }
  • Expected Output:
    {  
    "first_name_uppercase": "JANE"
    }

Practical Usage

Assume the following environment variables are set within a workflow:

{  
"first_name": "jane",
"last_name": "DOE",
"dob": "1985-06-15",
"gender": "F"
}

Here’s an example of using the helper functions within the workflow:

Example Usage:

{  
"first_name_uppercase": "${ToUpperCase(${env.first_name})}",
"last_name_lowercase": "${ToLowerCase(${env.last_name})}",
"dob_formatted": "${Date(${env.dob}, dd-MM-yyyy)}",
"gender_value": "${Replace(${env.gender}, {M: 1, F: 2})}",
"unique_id": "${GenerateUUID}"
}

Expected Output:

{  
"first_name_uppercase": "JOHN",
"last_name_lowercase": "doe",
"dob_formatted": "15-06-1985",
"gender_value": "2",
"unique_id": "6f9a3b33-54d5-4e0e-bc82-47a0c4fbc897"
}