XML tags using key value pair

Anubhav24
Mega Sage
Mega Sage

Hi Team,

Current Functionality I have is we are creating request XML using SOAP template , in this SOAP template under respective SOAP functions we are currently substituting values using scripts.

Ex : <reservelist>

<reserver key = "${reservelist.key}">${reservevalue}</reserver>

</reservelist>

This is in the soap template under repeatable tags.

My requirement is to send 2 key value pairs , how can I approach this because there needs to be two key value pairs and how will we substitute the key value pairs using script. Below should be sent in the request XML:

<reservelist>

<reserver key = "${reservelist.key}">${reservevalue}</reserver>

<reserver key = "${reservelist.key}">${reservevalue}</reserver>

</reservelist>

 Thanks in advance.

8 REPLIES 8

Abhay Kumar1
Giga Sage
Hi Anubhav, please check below article if this helps you, https://community.servicenow.com/community?id=community_question&sys_id=6de94729db5cdbc01dcaf3231f9619a8

Anubhav24
Mega Sage
Mega Sage

Hi Abhay,

Thanks a lot for your quick reply.The wiki link is not opening as it has been discontinued , any other source do you have?

There is also mentioned about take your data into a list , The other option i can think of is modify SOAP envelop template to parameterize entire list and populate list string by your self. ${listValue} Now in you script, you can iterate over your array of items and create a XML structure with which you can create XML string and call .setParameter(listValue, ). This will replace ${listValue} with your string.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

what you can do is this

1) form the XML string from your script and use that directly in request body instead of using variable substitutions.

Regards
Ankur

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