- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2025 10:36 AM
hi , I am working with API and I get my response content as shown below .. how do i use script in Action flow designer to convert to Array of objects ?
[
{
"transactionId": 11,
"typeOfRequest": "Add",
"priority": 0,
"employeeNumber": 121
},
{
"transactionId": 12,
"typeOfRequest": "Cancel",
"priority": 0,
"employeeNumber": 122
},
{
"transactionId": 13,
"typeOfRequest": "Cancel",
"priority": 0,
"employeeNumber": 1111
}]
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 12:02 PM - edited ‎06-04-2025 12:03 PM
This should be working based on my testing with your provided JSON example.
I think the issue is in your script. You have "outputs.requests = parsedArray," but according to your screenshot, your output variable is named "parsedarray. You script should look like this instead:
(function execute(inputs, outputs) {
var parsedArray = JSON.parse(inputs.ResponseContentString);
outputs.parsedarray = parsedArray; // The name of the variable for "outputs.<name>" should match your step outputs exactly.
})(inputs, outputs);
It might be useful to use more distinct names for your variables and outputs as that might be causing a little confusion. So instead of parsedarray for your step output, maybe something more like Employee Requests [employee_requests].
See attached for examples of what I tested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 06:27 AM
Hey there!
May need some more context here, but within a script what you've pasted can be parsed into an array by using:
JSON.parse(<response string>);
If you're building a data stream action for a Data Source, I'd recommend you take a look at the Dev site as it has a great tutorial for this: Data Stream Actions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 10:52 AM
Thank you , i tried as suggested above , but I still get null output response. I am attaching screenshots for reference.
My goal - I get a string which contains a jsonformatted value. I want to convert this to array of objects so that I can use for loop to iterate each child in array outside the action in flow designer .
  
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 12:02 PM - edited ‎06-04-2025 12:03 PM
This should be working based on my testing with your provided JSON example.
I think the issue is in your script. You have "outputs.requests = parsedArray," but according to your screenshot, your output variable is named "parsedarray. You script should look like this instead:
(function execute(inputs, outputs) {
var parsedArray = JSON.parse(inputs.ResponseContentString);
outputs.parsedarray = parsedArray; // The name of the variable for "outputs.<name>" should match your step outputs exactly.
})(inputs, outputs);
It might be useful to use more distinct names for your variables and outputs as that might be causing a little confusion. So instead of parsedarray for your step output, maybe something more like Employee Requests [employee_requests].
See attached for examples of what I tested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2025 12:13 PM
Excellent ! Thank you very much Zach ! appreciate your time and clear explanation ..