I can not reach the object 'additionalInfoList' by XML from SOAP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
I can not reach the object 'additionalInfoList' by XML from SOAP.
We pass this XML via Postman to ServiceNow, which is able to retrieve all the values via request.key, and we are able to send them as a response to Postman, so the call arrives successfully.
The problem arises when we try to access the additionalInfoList object via code. This object contains several items, which in turn are composed of paramname and paramvalue, which change both in number and value each time.
I tried using code to pass me the value logs via a for loop that accesses the object, but without success.
Below you will find the XML that we pass through Postman, the scripted Web Service code, the log outside the for loop that returns undefined for the number of items contained in the object, and finally the response from the scripted Web Service that returns the first value of the XML routingID, confirming that the XML has been correctly received by ServiceNow.
xml:
<soapenv:Envelope xmlns:soapenv="http://test.soap.org/soap/envelope/">
<soapenv:Body>
<ns3:TicketRequest xmlns:ns3="http://ticket.test.soap.org">
<ns3:TicketMessage>
<ns3:routingID>STLEACT000</ns3:routingID>
<ns3:sessionID>VFGAA5V0FNQA4ATDDGWATCB86EQ2</ns3:sessionID>
<ns3:requestedOperation>
<ns0:operationID xmlns:ns0="http://test.soap.org">UpdateActivity</ns0:operationID>
<ns0:operationDetail xmlns:ns0="http://test.soap.org"/>
<ns0:operationTimestamp xmlns:ns0="http://test.soap.org">2025-09-24T11:40:48.000+02:00</ns0:operationTimestamp>
</ns3:requestedOperation>
<ns3:sourceTicketID>WO0000009053605</ns3:sourceTicketID>
<ns3:destinationTicketID/>
<ns3:sourceTicketStatus>Assigned</ns3:sourceTicketStatus>
<ns3:requestedActivity>
<ns0:description xmlns:ns0="http://test.soap.org">test long</ns0:description>
<ns0:detectionTime xmlns:ns0="http://test.soap.org"/>
<ns0:severity xmlns:ns0="http://test.soap.org"/>
<ns0:priority xmlns:ns0="http://test.soap.org">Minor</ns0:priority>
<ns0:notes xmlns:ns0="http://test.soap.org">||</ns0:notes>
<ns0:object xmlns:ns0="http://test.soap.org"/>
<ns0:location xmlns:ns0="http://test.soap.org"/>
<ns0:additionalInfoList xmlns:ns0="http://test.soap.org">
<ns2:item xmlns:ns2="http://commonst.test.soap.org">
<ns2:paramName>DURATION</ns2:paramName>
<ns2:paramValue>1</ns2:paramValue>
</ns2:item>
<ns2:item xmlns:ns2="http://commonst.test.soap.org">
<ns2:paramName>LASTUPDATEDATETIME</ns2:paramName>
<ns2:paramValue>2025-09-24T11:40:48.000+02:00</ns2:paramValue>
</ns2:item>
<ns2:item xmlns:ns2="http://commonst.test.soap.org">
<ns2:paramName>LASTUPDATEBY</ns2:paramName>
<ns2:paramValue>WS LAYER</ns2:paramValue>
</ns2:item>
<ns2:item xmlns:ns2="http://commonst.test.soap.org">
<ns2:paramName>NE.SITE TYPOLOGY</ns2:paramName>
<ns2:paramValue>STD</ns2:paramValue>
</ns2:item>
<ns2:item xmlns:ns2="http://commonst.test.soap.org">
<ns2:paramName>SCHEDULING COMPLEXITY</ns2:paramName>
<ns2:paramValue>11</ns2:paramValue>
</ns2:item>
</ns0:additionalInfoList>
</ns3:requestedActivity>
</ns3:TicketMessage>
<ns3:TicketAttachments/>
</ns3:TicketRequest>
</soapenv:Body>
</soapenv:Envelope>
try {
(function TicketMessage(request, response) {
var routingID = request.routingID;
var description = request.routingID;
var status = request.sourceTicketStatus;
var vodafoneNumeberWo = request.sourceTicketID;
var priority = request.priority;
var location = request.location;
var xmlString = request.payload;
var xml = new XMLDocument2();
xml.parseXML(xmlString);
var nodes = xml.getNodes("//*[local-name()='additionalInfoList']/*[local-name()='item']");
gs.log('al soap script: additionalInfoList items count: ' + nodes.getLength());
for (var i = 0; i < nodes.getLength(); i++) {
var node = nodes.item(i);
var name = xml.getNodeText(".//*[local-name()='paramName']", node);
var value = xml.getNodeText(".//*[local-name()='paramValue']", node);
gs.log('al soap script: paramName=' + name + ' | paramValue=' + value);
}
response.routingID = routingID;
})(request, response);
} catch (err) {
gs.log("TicketService1 err" + err);
response.result = "TicketService1" + err;
}log: al soap script: additionalInfoList items count: undefined
postman:
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://test.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/test">
<SOAP-ENV:Body>
<TicketMessageResponse>
<routingID>STLEACT000</routingID>
</TicketMessageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
