cancel
Showing results for 
Search instead for 
Did you mean: 

Data transformation using Javascript Connector

jani-swinnen
Deputy Chef I
Deputy Chef I

Hi all,


I'm currently trying to do some data transformation using the Javascript connector but I can't figure out how to corrrectly configure the output. I'm trying to format a JSON body for a HTTP request to the Slack chat.scduleMessage endpoint.


In my recipe I set a variable to a JSON string, which I need to input into the Javascript connector, I then use JSON.parse to parse this string, but when I return the JSON.stringify on the next line, it ends up as a null value... My output schema is just a string named payload and in the next step the payload datapill is an empty string.


The JSON.parse does not give me an error so I have to assume the string gets parsed, but somehow, somewhere it ends up as null.


Does anyone have any experience in this situation?

1 ACCEPTED SOLUTION

gary1
Executive Chef III
Executive Chef III

I just ran a quick test and was able to get JSON.parse and JSON.stringify to work without issue. It might be how your script is returning the output. I found that part a bit tricky when first working with the JS connector.

I attached some images of my setup and script so you can see how it works and hopefully replicate it.

js_connector.png

js_log.png

  

js_output.png

View solution in original post

5 REPLIES 5

Patel0786
Deputy Chef II
Deputy Chef II

 i also create 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.

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