- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 03:28 AM
Hi All,
I need to fetch a value from the response body which i have received it from the SOAP step:
Fig:
Can some help me how do i fetch any value from the xml response which i am getting in the responsebody input variable?
Thanks,
Ak
Solved! Go to Solution.
- Labels:
-
flow designer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 11:34 AM
So the problem is the body which is returned from integration.
See formatted XML
Below works but it's not good for long time solution.
var response = inputs.response_body.toString();
var xmldoc = new XMLDocument(response);
if(xmldoc.toString().indexOf('name=') > -1){
var nm1 = (xmldoc.toString().split('name="')[1]);
var nm2 = (nm1.toString().split('"')[0]);
outputs.groupname = nm2;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 02:42 AM
Hi,
So you are getting xml as response; you can directly parse it and set the value
Is it not setting the outputs variable using this
var response = inputs.response_body;
var xmldoc = new XMLDocument(response);
var name = xmldoc.getNodeText("//row/@name");
outputs.groupname = name;
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 02:49 AM
I tried this but i am not getting anything for outputs.groupname=name;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 05:32 AM
Lets add logging so we know what we are getting
try below
var response = inputs.response_body;
gs.log("response: " + response, "Soap");
var xmldoc = new XMLDocument(response);
gs.log("xmldoc: " +xmldoc, "Soap");
var name = xmldoc.getNodeText("//row/@name")
gs.log("name: "+name, "Soap");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 06:10 AM
var response = inputs.response_body;
gs.log("response: " + response, "Soap");
For this i am getting soap xml response.
var xmldoc = new XMLDocument(response);
gs.log("xmldoc: " +xmldoc, "Soap");
No response
var name = xmldoc.getNodeText("//row/@name")
gs.log("name: "+name, "Soap");
since no response for the above step:
name: null

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 06:14 AM
Can you share what you got for response in logs ?