- 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-07-2020 10:16 PM
Had no option,
var xmlString = responseBody.toString();
var xmlClean = global.JSUtil.unescapeText(xmlString);
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(xmlClean);
with the above code I tried to convert ⁢ and > to < and > but it didn't worked. so thought to doing XML Parser step,
So can you help me out to fetch the values from the below response.
{
"Envelope": {
"Body": {
"name$": "Body",
"GetSupportSpecialistByLocationResponse": {
"name$": "GetSupportSpecialistByLocationResponse",
"GetSupportSpecialistByLocationResult": "<nda-response id=\"getassociations\" status=\"OK\"><association from_entity_guid=\"123456789\" business_process_role_guid=\"123456789\"><people></people><groups><row group_guid=\"123456789\" name=\"IND - BGL\" email=\"indbgl@xyz.com\" ordinal=\"0\" description=\"\" association_guid=\"123456789\"/></groups></association></nda-response>"
}
}
}
}
Thanks & Regards,
Ak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 12:55 AM
Hi,
Are you getting this as response?
{"Envelope":{"Body":{"name$":"Body","GetSupportSpecialistByLocationResponse":{"name$":"GetSupportSpecialistByLocationResponse","GetSupportSpecialistByLocationResult":"<nda-response id=\"getassociations\" status=\"OK\"><association from_entity_guid=\"123456789\" business_process_role_guid=\"123456789\"><people></people><groups><row group_guid=\"123456789\" name=\"IND - BGL\" email=\"indbgl@xyz.com\" ordinal=\"0\" description=\"\" association_guid=\"123456789\"/></groups></association></nda-response>"}}}}
Also is this in scoped app since you are using XMLDocument2()
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 01:06 AM
Yes, i am getting this response from the XML Parser step.
Right now this action is in global, later will make it as scoped.
Can you please guide me to fetch those values from the above response.
Regards,
Ak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 01:23 AM
Hi,
what does this print?
var responseBody = inputs.response_body;
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 01:54 AM
var responseBody = inputs.response_body;
It print the soap response:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetSupportSpecialistByLocationResponse xmlns="http://nda.sys.com/">
<GetSupportSpecialistByLocationResult>
<nda-response id="getassociations" status="OK">
<association>
<people></people>
<groups>
<row name="India - Banaglore" email="indbgl@xyz.com" />
</groups>
</association>
</nda-response>
</GetSupportSpecialistByLocationResult>
</GetSupportSpecialistByLocationResponse>
</soap:Body>
</soap:Envelope>
Exact response...