
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 05:40 AM
Hi All,
How do i parse an xml response that i get from soap message ?
I want the sys_id from the response.
EX- i got a following response:
<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><insertResponse xmlns="http://www.service-now.com/u_fetch_incidents_19057"><sys_id>62c20f0edb222200d17ad6fdbf9619d5</sys_id><table>incident</table><display_name>number</display_name><display_value>ABC0010111</display_value><status>inserted</status></insertResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
I want the value of the sys id that i have highlighted to be used ahead in my code.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 11:45 PM
Hello Vineetha Rohra,
I have store your response in one field and written business rule according to your requirement its working fine.
script:--
var res=current.getValue('u_response');
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(res);//you can user response body here.
var num = xmlDoc.getNodeText('//sys_id');//here you write whta you want from response.
gs.addInfoMessage(num);
HOPE THIS HELPFUL!!!!! MARK CORRECT OR HELPFUL.
Thanks,
Mohammed Iqbal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 05:51 AM
Hi Vineetha,
Follow this link.it will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2017 05:22 AM
Hi Vineetha,
Not sure whether you found answer for your question, but here is the way to fetch the value for sys_id tag value from the xml by xml parsing
var xmlString = ''; // your xml string which is soap response
var xmldoc = new XMLDocument();
gs.print("Sys id is:"+xmldoc.getNodeText("//insertResponse/sys_id"));
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
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
‎03-20-2018 10:53 PM
I'm facing the same issue with below response.
---------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<ServiceIncident xmlns="http://b2b.ibm.com/schema/IS_B2B_CDM/R2_2" xmlns:m1="http://b2b.ibm.com/schema/IS_B2B_CDM/R2_2" xmlns:m3="http://www.ibm.com/maximo" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RequesterID>IN10003273</RequesterID>
<ProviderID>INC0376178</ProviderID>
<Transaction><Acknowledge>1</Acknowledge>
<StatusCode>0</StatusCode>
<Comment>Success - No Errors Encountered</Comment>
<TransactionName>Problem_Submittal</TransactionName>
<TransactionType>2</TransactionType>
<TransactionDateTime>2016-09-14T01:46:55Z</TransactionDateTime>
<TransactionNumber/>
<TransactionRouting>MX::AIAICDSNINC</TransactionRouting>
</Transaction>
</ServiceIncident>
===================================
I need RequesterID from above.
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(responseBody);
var num = xmlDoc.getNodeText('//RequesterID');
Not working. any suggestion??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2018 11:45 PM
Hello Vineetha Rohra,
I have store your response in one field and written business rule according to your requirement its working fine.
script:--
var res=current.getValue('u_response');
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(res);//you can user response body here.
var num = xmlDoc.getNodeText('//sys_id');//here you write whta you want from response.
gs.addInfoMessage(num);
HOPE THIS HELPFUL!!!!! MARK CORRECT OR HELPFUL.
Thanks,
Mohammed Iqbal