cancel
Showing results for 
Search instead for 
Did you mean: 

Data Transformation Using Workato JS Connector

Patel0786
Not applicable

 i created a recipe for data transformation using JS snippet by workato, in this recipe i have a group of JSON object and i'm doing data transformation like converting firstName, lastName etc  to - (based on requirement) using JS code.

(in this recipe i put the complete json data in logger)

Recipe:-  https://app.workato.com/recipes/54842488?st=22358e2f16126f8b0aa51e349ae0de7633781b47a307c56fdd951d59... 

now i want to use the csv data in place of direct data passing in logger message, how to do i don't have an idea.

i tried by parsing the csv data action but it's throwing error.

 

2 ACCEPTED SOLUTIONS

Hi @Patel0786  the proposed method will use just 2 tasks, no matter how many elements are in the JSON list. There’s no need for For Each or loops to generate the CSV file.

View solution in original post

5 REPLIES 5

javier-riesco
Workato employee
Workato employee

Hey @Patel0786 , how about a simpler approach WITHOUT the JS code? check this example: 

https://app.workato.com/recipes/54939691?st=82110955554ef33874944e291d2ff20788bb9f4c9cac02831996aa64...

hey @javier-riesco thaks for your solution

- your approach is also correct but i want to Use Js code block to transform the data uisng JS to minimise the task count for data manipulation because if we use for each loop for iterate the record then it will consume one task per row , and in my case there is limitation on task consumption limit by using the JS code we can use the for loop and  iteration also possible with less task count.

Hi @Patel0786  the proposed method will use just 2 tasks, no matter how many elements are in the JSON list. There’s no need for For Each or loops to generate the CSV file.

mppowe
Executive Chef I
Executive Chef I

The transformations seem simple enough, so I think you could take the input JSON, use the Parse JSON action to convert it to the datapill structure, then use the Parse CSV action where you feed in the  JSON list and use the .to_csv function.  Then you give it the schema for the CSV and you can do you transformations in that step, minimizing both complexity and task usage.

I didn't create a new recipe of my own to do these exact steps, so there may be a gap somewhere but in general I think this path is probably worth exploring for your solution.  Another possibility is to take the JSON and convert it to a Collection, then do you bulk transformations there using SQL statements, then converting that to CSV.