Advanced Transformations
need something more complex than basic transformations? want to write the code yourself? you can use advanced transformations to write complex jsonata expressions, which gives you significant flexibility to transform data according to your needs see jsonata docs https //docs jsonata org/overview\ html to assist you in writing expressions jsonata requires double quotes ( " ) for all string values single quotes ( ' ) are not valid string delimiters and will cause expressions to fail to include a literal double quote inside a string, escape it with a backslash ( \\" ) for example $stringcapitalize("this is a \\"test\\"") see quoting rules for string parameters https //app archbee com/docs/wdlpsa7glls1ghfgxbo9d/taiy8leyf1zvgmhhdybcf#quoting rules for string parameters in the main transform data guide for details once you click switch to advanced in the block header, you cannot revert the block to a basic (no code) chain for that block a confirmation dialog asks are you sure you want to switch to advanced mode? and explains that switching is irreversible and that existing transformations for the block will be converted click confirm to continue or cancel to stay in basic mode advanced mode layout in advanced mode, each block uses the same three areas described in using the transform data native action https //app archbee com/docs/wdlpsa7glls1ghfgxbo9d/taiy8leyf1zvgmhhdybcf area advanced mode behavior inputs declare the data the block can use ( + add property ), or let add playbook property / add expression add rows for you mark inputs as sensitive with the lock icon transformation a code editor for the jsonata expression under the editor, use add playbook property and add expression to map playbook data in one step use code editor configuration to set line numbers, folding, and theme (for example dracula, monokai, or eclipse) test hidden until you click test in the block header then provide test data, run test , review result or discovered outputs , and use copy inputs to editor when needed in the code editor , you can paste jsonata from elsewhere every playbook backed value you use must have a row in the inputs list the editor offers autocomplete or intellisense style help for declared inputs and updates as you add or change inputs add playbook property and add expression in advanced mode, the footer under the code editor includes control what it does add playbook property opens the playbook property drawer when you select a property, turbine adds the mapping to inputs and inserts the jsonata path at the cursor in the editor add expression opens the expression dialog when you enter an expression, turbine adds the mapping to inputs and inserts the path at the cursor input names follow the same nested naming as in earlier transform data versions (for example actions http1 result body or event data href ) you can still review and edit every input in the inputs area use + add property when you prefer to declare inputs manually before writing jsonata sensitive data is set per input in the inputs list when might you want to use advanced transformations? the most common need is transforming one object structure into a different structure for use within the playbook transforming one object structure to a different structure use case avery takes data from a slack event and restructures it to swimlane’s common data model avery uses an advanced transformation block and clicks add playbook property under the code editor and selects fields from the slack trigger (turbine adds them to inputs and inserts paths in the editor), or defines inputs manually with + add property writes or refines jsonata in the code editor , using dot or bracket paths for objects and arrays as required clicks test in the block header to open the test panel, runs test , and reviews discovered outputs when needed avery sets up a webhook trigger for slack events, adds a transform data action, switches a block to advanced , and builds an object (for example id, type, timestamp) from those inputs visit the jsonata exerciser https //try jsonata org/ to verify and/or practice writing jsonata expressions add playbook property and add expression update inputs and the expression together if you delete or rename an input in the inputs panel, turbine rewrites matching references in the expression (deleted inputs become $deleted in the code) if you remove a reference only by editing the expression, remove the unused input yourself in inputs keep the inputs list aligned with what the expression uses handle errors with $error and $assert in advanced mode, you can use swimlane jsonata extensions to fail a block with a clear, custom message function purpose $error(message) stop evaluation and fail the block with the message you provide $assert(condition, message) fail the block when condition is false, using message as the error text when the block fails, turbine records the message on the playbook run starting in turbine 26 2 0 , that error is also exposed as a playbook property so downstream actions can map $actions \<transformationactionname> error \<blockkey> message (and related fields) without parsing the run log manually example — validate before transform $assert($exists(email) and $string(email) != "", "missing required field email") { "email" email, "domain" $split(email, "@")\[1] } if email is missing, the block fails with missing required field email a later action can reference $actions mytransform error block 1 message to log the failure, update a record, or branch in a condition for property paths and downstream mapping, see reference transformation errors in downstream actions https //app archbee com/docs/wdlpsa7glls1ghfgxbo9d/taiy8leyf1zvgmhhdybcf#reference transformation errors in downstream actions in the main transform data guide see also using the transform data native action https //app archbee com/docs/wdlpsa7glls1ghfgxbo9d/taiy8leyf1zvgmhhdybcf — block setup, testing, outputs, and quoting rules