- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 08:06 AM
Hi Community,
I have developed an outbound integration in ServiceNow. For failed transactions, i have created a retry policy and a business rule to create an incident. However while parsing xml, it is giving null value.
I want to parse the below parameter:
\
In my BR, i am using:
var payld = current.input_queue.payload;
var snowgrp = gs.getXMLText(payld,"//http_status_code");
gs.log("Value of snowgrp is"+snowgrp);
Logs:
Any help on this would be appreciated.
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 01:41 PM
Well you could either use
var xmlDoc = new XMLDocument(current.input_queue.payload,true);
inc.work_notes = "The incident failed to send notification to end user. Error code is " + xmlDoc.getAttribute("//parameter[@name=\"http_status_code\"]","value");
or
var xmlDoc = new XMLDocument(current.input_queue.payload,true);
var errorCode = xmlDoc.getAttribute("//parameter[@name=\"http_status_code\"]","value");
inc.work_notes = "The incident failed to send notification to end user. Error code is " + errorCode;
Just depends if you want to create a variable for it or just use the parsing directly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 04:05 PM
Try this, had to change the way of getting the errorcode as well since the XML contains another XML with it's own namespace.
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(current.input_queue.payload);
var node = xmlDoc.getNode("//parameter[@name=\"http_status_code\"]");
var errorCode = node.getAttribute("value");
var incidentNumber = xmlDoc.getNodeText("//tem:incidentNumber");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2018 06:28 AM
Hi Simon,
The problem here is : incident number is located in different payload. Its not in input queue payload.
I have written below code:
//Parse Http error code;
var xmlDoc = new XMLDocument(current.input_queue.payload,true);
var errorCode = xmlDoc.getAttribute("//parameter[@name=\"http_status_code\"]","value");
//Parse Incident number;
var xmlDoc2 = new XMLDocument2();
xmlDoc2.parseXML(current.retry_queue_entry.payload);
var incidentNumber = xmlDoc2.getNodeText("//tem:incidentNumber");
I am able to extract error code. But incident number is still null.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2018 08:39 AM
Thanks Simon and abhinay for your help. I have created a seperate thread for second question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 01:04 PM
Please check if this helps. I have tried to test in background script and it worked. This might help you to achieve your result. Please update the script as per your need. You may have to update the xmlstring with payld.
var xmlString = "<?xml version='1.0' encoding='UTF-8'?>"+
"<parameters>"+
"<parameter name='message_header' value='head123'/>" +
"<parameter name='http_status_code' value='404'/>"+
"<parameter name='message_content2' value='content456'/>" +
"</parameters>";
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(xmlString);
var itertr = xmlDoc.getNode("//parameters").getChildNodeIterator();
while(itertr.hasNext()){
var n = itertr.next();
var xmlDoc1 = new XMLDocument2();
xmlDoc1.parseXML(n);
var node = xmlDoc1.getNode("//parameter");
if(node.toString().split(' ')[1].split('=')[1].replace(/"/g, "") == 'http_status_code'){
var nodeValue = node.toString().split(' ')[2].split('=')[1].replace(/[^a-zA-Z0-9]/g, "");
gs.print(nodeValue);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2021 09:40 AM
we have below xml request:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/><SOAP-ENV:Body>
<tns:CreateIncidentVBMRequest xmlns:tns="http://group.vodafone.com/schema/vbm/service/incident/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tns:IncidentVBO>
<cmn:IDs xmlns:cmn="http://group.vodafone.com/schema/common/v1">
<cmn:ID>NET09552959</cmn:ID>
</cmn:IDs>
<cmn:Name xmlns:cmn="http://group.vodafone.com/schema/common/v1">TEST TICKET</cmn:Name>
<cmn:Desc xmlns:cmn="http://group.vodafone.com/schema/common/v1">
NO MATCH FOUND.</cmn:Desc>
<cmn:Type xmlns:cmn="http://group.vodafone.com/schema/common/v1">Proactive Incident</cmn:Type>
<cmn:Status xmlns:cmn="http://group.vodafone.com/schema/common/v1">New</cmn:Status>
<cmn:Created xmlns:cmn="http://group.vodafone.com/schema/common/v1">14/01/2021 14:28:09</cmn:Created>
<vbo:Details xmlns:vbo="http://group.vodafone.com/schema/vbo/service/incident/v1">
<vbo:SeverityCode>3</vbo:SeverityCode>
<vbo:PriorityCode>3</vbo:PriorityCode>
</vbo:Details>
<vbo:Roles xmlns:vbo="http://group.vodafone.com/schema/vbo/service/incident/v1">
<vbo:Requester>
<cmn:Organisation xmlns:cmn="http://group.vodafone.com/schema/common/v1">
<cmn:IDs>
<cmn:ID schemeName="ProfileID">RANK1232145</cmn:ID>
<cmn:ID schemeName="VodafoneProfileID"/>
</cmn:IDs>
<cmn:Name>RANK</cmn:Name>
<cmn:LocalTradingName>MorrisonsB2B</cmn:LocalTradingName>
</cmn:Organisation>
<vbo:ContactPoints>
<vbo:ContactPoint>
<cmn:Email xmlns:cmn="http://group.vodafone.com/schema/common/v1">
<cmn:FullAddress/>
</cmn:Email>
<cmn:Telephone xmlns:cmn="http://group.vodafone.com/schema/common/v1">
<cmn:SubscriberNumber/>
</cmn:Telephone>
</vbo:ContactPoint>
</vbo:ContactPoints>
</vbo:Requester>
</vbo:Roles>
<vbo:Parts xmlns:vbo="http://group.vodafone.com/schema/vbo/service/incident/v1">
<vbo:Services>
<vbo:Service>
<cmn:Name xmlns:cmn="http://group.vodafone.com/schema/common/v1">VONE-C SERVICE</cmn:Name>
<vbo:ServiceArea>VOICE VONE-C</vbo:ServiceArea>
<vbo:Specification>
<cmn:IDs xmlns:cmn="http://group.vodafone.com/schema/common/v1">
<cmn:ID>0</cmn:ID>
</cmn:IDs>
</vbo:Specification>
</vbo:Service>
</vbo:Services>
<vbo:IncidentSites>
<vbo:IncidentSite>
<cmn:IDs xmlns:cmn="http://group.vodafone.com/schema/common/v1">
<cmn:ID>NO SITE</cmn:ID>
</cmn:IDs>
<cmn:Name xmlns:cmn="http://group.vodafone.com/schema/common/v1">NO SITE</cmn:Name>
<vbo:ContactPoints>
<vbo:ContactPoint>
<cmn:Postal xmlns:cmn="http://group.vodafone.com/schema/common/v1">
<cmn:Street/>
<cmn:Town/>
<cmn:Country/>
<cmn:County/>
<cmn:PostCode/>
</cmn:Postal>
</vbo:ContactPoint>
</vbo:ContactPoints>
</vbo:IncidentSite>
</vbo:IncidentSites>
<vbo:Symptom>
<cmn:Name xmlns:cmn="http://group.vodafone.com/schema/common/v1">CALL TRANSFER</cmn:Name>
<cmn:Categories xmlns:cmn="http://group.vodafone.com/schema/common/v1">
<cmn:Category>EXTENSION MOBILITY CROSS CLUSTER</cmn:Category>
</cmn:Categories>
<vbo:DiscoveredDateTime>14/01/2021 14:28:09</vbo:DiscoveredDateTime>
</vbo:Symptom>
</vbo:Parts>
</tns:IncidentVBO>
</tns:CreateIncidentVBMRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In this we are trying to fetch nodes value but getting null everytime, Can you please help in that, below we are using to fetch nodes and its value,
var xmlDoc = new XMLDocument(requestXML,true);
var vshort_description = this.xmlDoc.getNodeText("//Body/CreateIncidentVBMRequest/IncidentVBO/Name");
var vstatus = this.xmlDoc.getNodeText("//Body/CreateIncidentVBMRequest/IncidentVBO/Status");
it tried it in through backgroun script but did not work,
var nodeName = gs.getMessage('Test XML');
//gs.print(nodeName);
var xmlDoc = new XMLDocument(nodeName,true);
var vshort_description = xmlDoc.getNodeText("//SOAP-ENV:Body/CreateIncidentVBMRequest/IncidentVBO/Name");
gs.print(vshort_description);
'Test XML :- contains same request xml