How to use JSON object in Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 06:50 AM - edited 02-16-2024 06:56 AM
Hi,
There is a Record Producer, after submitting it a record will be created in Case table and there is a field called "JSON Output" which stores data of submitted RP
JSON body looks as below
{
“field1”:{
“original_value”:””,
“changed_value:””,
“field_display_value:””
},
“field2”:{
“original_value”:””,
“changed_value:””,
“field_display_value:””
},
…
}
Now, I wanted to use the data stored in this "JSON Output" field on Workflow. The condition looks like below
Now I wanted to know how to do below 2 things
1. Get JSON data from "JSON Output" field into JSON Object[Action in flow]
2.Here JSON object stores 2fields, so field1 should considered in first if block and I need to write field1!=empty, same for 2nd field.
How can I achieve this.
Guidance is appreciated.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 07:06 AM - edited 02-16-2024 07:07 AM
Hi @Aruna Sree Yela ,
Please go through this article https://docs.servicenow.com/bundle/washingtondc-build-workflows/page/administer/flow-designer/concep...
If you find my answer helpful do hit the like button and mark my answer helpful
Thanks,
Saurabh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 07:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 07:48 AM
So @Aruna Sree Yela ,
Can you share the snap of the flow or is it written in the runscript node of the workflow.
if yes then you should have a condition like this.
if you Store JSON body in result variable;
result =
{
“field1”:{
“original_value”:””,
“changed_value:””,
“field_display_value:””
},
“field2”:{
“original_value”:””,
“changed_value:””,
“field_display_value:””
},
…
}
var result2 = JSON.parse(result); // parse to get the value
if (result.field1){
return result2.field1;
}
else{return return result2.field2;} // if not field one
This should work @Aruna Sree Yela
If my answer found useful do mark the helpful button,
Thanks,
Saurabh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2024 01:03 AM
Hi @saurabh_dubey ,
I have not written workflow yet, as I'm not clear about how can I do it with the JSON. Can you please guide me on this. If possible please provide me the snip.
Thanks