- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2022 01:02 PM
Greetings,
We have an action which makes a rest call to our monitoring service. It then returns a json string, from which we need a single field.
We attempted to use the built-in JSON parser to grab that field, but (at the recommendation of HI support) were told to just use a custom script.
That custom script works, and then it stops working because the step itself refuses to accept the variable (the JSON string). I made a HI ticket for this problem, but the response is slow and so far not helpful, so I thought I would post here.
Here is the script step and script:
Here is an execution where that input variable jsonString is acquired and used. You'll see that accepts the JSON body from the REST string and passes it into the field :
Then there are occasions where we test the same device and the jsonSTRING input variable is simply not defined by the script step, and the entire flow hangs, waiting indefinitely for that variable that never comes:
The execution log does not have a row for the input variable. Obviously, the script does not run because it needs that value.
Any info, help, references, even a suggested change to how we are doing this are welcome.
Thanks.
Solved! Go to Solution.
- Labels:
-
flow designer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2022 06:54 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2022 01:51 PM
Hi Robert,
From your example screenshot the response you are receiving does not have any values in the devices array. This would make sense why your objid output variable is empty. Your action and script are correct but the response needs to return those values. That would not be an issue on ServiceNow side. Hopefully that helps.
---David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2022 02:27 PM
The Flow itself uses the action to check if there is an object. When there is, the flow updates it with the objid, when there is not, the flow creates the object.
This is all functional to the way we are using it.
Ultimately do you see that the second instance of the script does not even call the input variable? (In the first one it calls the JSON which is empty, demonstrating that even if it is empty sometimes it still calls it).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2022 03:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2022 06:39 AM
Thanks for taking the time to understand even re-articulate it. Much appreciated.
I added your line 4 and ran it, and find the same problem:
Even when there is no objid, there is still a response body, which is not being passed to the script step as an input variable to begin with. The "Step Configuration" part of the script step should be passing that input variable whether there is an objid or not, as it does not even look for that until after the variable is received.
In the case of this test, there is both a response body and an objid, so it makes a good demonstration of the problem. (I think, let me know if I am missing something here of course).