Transform Expressions
Transform expressions allow you to manipulate and compute form data before saving it to the integrated account. By using JSONata expressions, you can compute additional fields, modify existing data, or restructure the payload for storage or integration.This step comes after you have added the neccessary fields in your RapidForm
Setting Up Transform Expressions
Transform expressions are configured to preprocess form data before it is stored. This feature is useful for scenarios where fields need to be computed dynamically or existing fields require adjustments. Toggle the Transform data before saving option to enable this feature.
Configuration Options
1. Example Input Data (JSON)
- Provide sample JSON data to simulate and test your transformation logic.
- Example:json
{ "projects": [ { "value": 1 }, { "value": 2 }, { "value": 3 } ] }
2. Transformation Expression (JSONata)
- Write a JSONata expression to transform the input data.
- Expected Output:
- A single JSON object representing the transformed data.
- You can use the
$merge
function to merge computed fields with the original input.
- Example Expression:jsonata
$merge([ $, { "totalProjects": $count(projects), "timestamp": $now() } ])
- Explanation:
$merge
combines the original data ($
) with computed fields."totalProjects"
is computed using$count(projects)
, which counts the number of items in theprojects
array."timestamp"
adds the current date and time using$now()
.
3. Output
Displays the result of applying the transformation expression to the example input data.
For the Above Example:
Output:
json{ "projects": [ { "value": 1 }, { "value": 2 }, { "value": 3 } ], "totalprojects": 3, "timestamp": "2024-12-04T10:15:00.000Z" }
Transform expressions in RapidForm offer an efficient way to customize and preprocess form data before saving it to an integrated account. By leveraging JSONata expressions, you gain the flexibility to dynamically compute fields, modify existing data, or restructure the payload to match the requirements of your integration