Articles in this section

JavaScript transformations

The JavaScript-based tool is recommended if you need to perform complex transformations. You can use the toggle button on the top of the transformations screen to move between the standard Rules and the JavaScript editor.

Note: You can’t define transformations in the Rules and JavaScript together. If you apply rules first, and then toggle to the JavaScript editor, your predefined rules are ignored.

The JavaScript editor uses one of your own pre-made scripts, to which you can add transform functions using Insert transform stub. The function is passed in a single argument (return options.record) with the following fields:

'record' - object {} or array [] depending on the data source.
'settings' - all custom settings in scope for the transform currently.

There are several use cases for more complex JavaScript transformations:

  • Copy a body field into all the elements of a list.
  • Copy a list field into a body-level field.
  • Remove, Add, or Rename fields based on certain conditions.
  • Dynamically inspect and restructure an entire record.
  • Iterate through a list to perform a calculation, and then store the calculation results in a body field.
  • Iterate through lists within lists, then reorganize all elements into a brand new list.

In this example, you’re adding a list of names to the Crew field based on a spaceship’s launchpad.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.