cancel
Showing results for 
Search instead for 
Did you mean: 

How have you used JavaScript and Ruby actions?

kale-bogdanovs
Workato employee
Workato employee

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?

3 REPLIES 3

akohrs
Deputy Chef II
Deputy Chef II

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.

mppowe
Executive Chef I
Executive Chef I

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).

anthony-oconnor
Deputy Chef I
Deputy Chef I

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.