Parse SOAP xml response

Vineetha Rohra1
Giga Guru

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.

1 ACCEPTED SOLUTION

Mohammed_Iqbal
Tera Guru

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);

 

find_real_file.png

 

HOPE THIS HELPFUL!!!!! MARK CORRECT OR HELPFUL.

Thanks,
Mohammed Iqbal


   

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Vineetha,

Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Nitin14
Kilo Contributor

Hi Mohammad,

 

In my case, response is a Session token which I got after logging in to target system. I want to store it in a variable on form for further use it for subsequent calls. How I can do that?

 

Thanks,

Nitin