โ10-20-2021 10:48 PM
Hi Pros,
A few weeks back we published a quick guide on using JavaScript for complex data-wrangling. Curious to know about your experiences with the JavaScript and Ruby actions in your own automations. How do you decide when to bring in code for transformations instead of using formulas, or conditional logic in the recipe builder?
โ10-20-2021 11:04 PM
you might reach out to Mark Dailey (mdailey@psyncopate.com) as he and I are working on a cool project and he used Ruby in some wrangling/parsing.
โ10-21-2021 12:42 PM
I had a case where I had a nested, delimited string to parse and couldn't find a way to handle it with OOTB actions, so had to learn a little Ruby to do it. Our implementation consultant was the one who actually landed on using Ruby instead of OOTB actions (JS wasn't an option yet). The string format was <fund1>:<amount1>|<fund2>:<amount2>|etc.
For example:
00156:20.0|0999:100.0|UNRES:25.0
I had to split it into fund:amount pairs and then map it to an array of objects, then loop through that array to get an internal ID for each fund code. The purpose of the recipe was to parse that string and "enrich" it with the internal ID, and it proved a lot more complicated than I expected. I think the array handling was counter-intuitive to me (as a programmer) b/c you couldn't just "enrich" an array, rather, we had to create a new array and loop one at a time over the existing array, copying over each element (now including the internal ID).
โ10-21-2021 06:06 PM
yeah I had similar situation - raw data coming in was at a nested line level grouped by user, i had to break out the lines, then regroup based on expense type. That's very simiple using JS object data structure, and no simple way to do it with OOTB recipe actions. The recipe breaks out and collects lines into a single large list, which is then passed to the JS step which groups as needed before loading into target system
to date that's the only time I've had to resort to using "real" programming - the OOTB are generally pretty powerful.