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.
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.
02-07-2023 09:46 PM
Hello Gary,
I am Jagadeesh. I am working on the same Usecase that Jani was explaining. I wanted to refer to your setup and Script but I couldn't find the attached images. Could you please share them once again?
Thanks in Advance.
02-08-2023 05:55 AM
Hi @Saichand,
I have updated Gary's replies with the original screenshots of his solution. I have also attached them to this reply (see below).
Thank you,
Meghan
08-24-2022 10:44 AM
Thank you Gary,
I managed to figure it out with the help of your screenshots.
The problem was that I changed the syntax when trying to fix a previous bug, and in doing so I removed the curly braces surrounding the input and return values. I think that's the main reason for my function to return a null value.