- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 10:12 PM
hi all,
I am using Flow Designer and inside that Flow Action is called. Output of Flow Action is JSON (Response Body)
{"ObPrivateID":"61603","ObCityID":"86af8877c919712c332b3d47f3a01280b43756a","cacheKey":null,"errorCode":null,"errorMessage":null,"hasError":false}
Need to fetch ObPrivateID from response body and assign that value(61603) to a field , in Flow designer.
Please suggest.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 11:04 PM
Hello @Ujjwal1
Are you returning the entire object from the action?
You can try something like in script step and access the object in that and return only the ObPrivateID from outputs.
var ob = {
"ObPrivateID": "61603",
"ObCityID": "86af8877c919712c332b3d47f3a01280b43756a",
"cacheKey": null,
"errorCode": null,
"errorMessage": null,
"hasError": false
};
var obStr = JSON.stringify(ob);
var obPar = JSON.parse(obStr);
gs.info(obPar.ObPrivateID); //61603
Hope it helps:)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 11:00 PM
Hi @Ujjwal1
You can either make use of JSON parser step https://docs.servicenow.com/bundle/washingtondc-integrate-applications/page/administer/flow-designer...
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 11:04 PM
Hello @Ujjwal1
Are you returning the entire object from the action?
You can try something like in script step and access the object in that and return only the ObPrivateID from outputs.
var ob = {
"ObPrivateID": "61603",
"ObCityID": "86af8877c919712c332b3d47f3a01280b43756a",
"cacheKey": null,
"errorCode": null,
"errorMessage": null,
"hasError": false
};
var obStr = JSON.stringify(ob);
var obPar = JSON.parse(obStr);
gs.info(obPar.ObPrivateID); //61603
Hope it helps:)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2024 11:05 PM
Alternatively, you can make use of below code in the variable you want to set to parse and set the JSON value :
var keys= JSON.parse(inputJSON); // Please replace inputJSON with your variable
var id = keys.<your key>; //Replace key with your JSON key
return id;
Please mark this response as correct and helpful if it assisted you with your question.