You can apply a transform rule or JavaScript to convert large export or import JSON/XML data to a smaller JSON structure that is more readable and easier to understand.
Transform rules allow you to:
- Flatten complex JSON structures
- Provide meaningful field names
- Select a limited set of fields for processing
This article generally explains how to implement transform rules, but for a complete list of transform rules, see the Transformation Rules Guide.
Contents
Deprecated: Multiple (chained) transforms
These complex rules, used most commonly in async API exports, are no longer available in the current version of integrator.io; only single-step transforms are supported. (Instead of using multi-step, rule-based transforms, you can rewrite complex transforms within a single JavaScript function, when migrating your integrations.)
Define transform rules
Use the following steps to apply transform rules:
- On the import or export page, click the pencil icon beside the Transform Rules field.
- Click the Rule-#1 drop-down list box, and then click Edit Rule.
- In this rule, the first level of transformation is automatically done. You can perform modification under Pre Transformed Record section if required.
Note: All the received fields are available at this level. If you create multiple rules, these fields are then passed on to the next rule.
- Click Accept.
- From the Rule-#1 drop-down menu, click Add Next Rule.
- From Rule-#2, click Edit Rule.
- Under Transform Mappings, map the required fields. This simplifies the JSON structure further.
Note: integrator.io only passes mapped fields into the flow, so verify that all required fields are accurately mapped.
- Click Accept.
- Click Save.
Using JavaScript instead of transform rules
You can toggle between rules and JavaScript to implement transform logic with the button at the top of the transform editor. Rules are the preferred option for simple transform logic, but you can use JavaScript for complex transform logic. You can't define both rules and JavaScript in a transformation. If you apply rules, then toggle the transformation editor to JavaScript to enter transform criteria, JavaScript takes precedence, and any previously defined rules are ignored.
Common scenarios for JavaScript transforms:
- Copy a body field into all the elements of a list
- Copy a list field into a body level field
- Dynamically inspect and restructure an entire record
- Iterate through a list to perform a calculation, and then store the results of the calculation in a body field
- Iterate through lists within lists, and then reorganize all elements into a new list
Comments
0 comments
Please sign in to leave a comment.