- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 11:17 AM
We built an ACTION in Flow Designer that returns JSON from a REST endpoint that looks like this:
{"version":"21.4.73","treesize":1,"devices":[{"objid":12783,"objid_raw":12783,"status":"Up","status_raw":3,"name":"addc.com","name_raw":"addc.com"}]}
We want to have just the "objid" return as an output from the action, so we added an input step after the REST call using the JSON PARSER:
The objid string is not selectable as an output (the data pill picker or drag-and-drop both just ignore the attempt to select it).
I created a HI ticket, and was told to make a custom script for grabbing this. I don't know how to do this.
I added a script step, and then hacked at it a bit, but to no avail.
I would like a script which isolates the number of the "objid" value and makes that number selectable in the action step outputs. Any help or direction will be greatly appreciated.
Thanks!
--Robert
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 03:13 PM
Hi Robert,
I created a custom action for this. Please look over how it is working. You will need to provide the JSON string
as an input, from whichever data pill is storing it. In my example, I am just passing it in via manual input for testing.
Inputs: For you this will be the data pill that contains the JSON response
Script step:
Takes the JSON string, parses it into a JSON object.
Assigns outputs.objid to the objid property in the JSON obj.
Outputs: Return the objid that we retrieved in the script step to the main flow.
Testing action - passing in the JSON string (response)
Result: objid is 12783
Hope this helps.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 03:13 PM
Hi Robert,
I created a custom action for this. Please look over how it is working. You will need to provide the JSON string
as an input, from whichever data pill is storing it. In my example, I am just passing it in via manual input for testing.
Inputs: For you this will be the data pill that contains the JSON response
Script step:
Takes the JSON string, parses it into a JSON object.
Assigns outputs.objid to the objid property in the JSON obj.
Outputs: Return the objid that we retrieved in the script step to the main flow.
Testing action - passing in the JSON string (response)
Result: objid is 12783
Hope this helps.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2022 06:46 AM
Worked like a charm. Thank you Dan!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2022 09:46 AM
Dan,
Should I be so lucky to have you available to continue troubleshooting here. Some of the response bodies are NULL, at which point we want the action to do something different. Can you advise how to make this if / else work?
(function execute(inputs, outputs) {
var jsonString = inputs.jsonString;
var jsonObj = JSON.parse(jsonString);
if (jsonObj.devices.length !== 0) {
outputs.objid = jsonObj.devices[0].objid.toString();
}
else { outputs.objid = null };
})(inputs, outputs);
--Robert