โ08-23-2022 10:37 AM
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?
Solved! Go to Solution.
โ08-23-2022 04:18 PM - last edited on โ02-08-2023 05:53 AM by meghan-legaspi
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.
โโ
โ
โ10-16-2024 10:42 PM
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.