Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to pass the Dynamic value using Soap Message?

lvakare
Kilo Contributor

As we have ${current.short_description} (Here current refers to Incident table) to read the values dynamically In REST.How to pass the same thing Using Soap Message.Instead of passing ${current.short_description} in variable section .I want to pass short description value from incident table to setStringParameter.I am using below script:

try {

var s = new sn_ws.SOAPMessageV2('SoapMSG', 'methodName');

s.setStringParameter('field.fieldName', 'incident.short_description');

s.setStringParameter('field.applicationName', 'ven011');

s.setStringParameter('field.clearTextValue', 'Hello');

var response = s.execute();

var responseBody = response.getBody();

var xmlDoc = new XMLDocument2();

xmlDoc.parseXML(responseBody);

var resultText = xmlDoc.getNodeText('//clearTextValue');

current.description = resultText ;

current.update();

}

catch(ex) {

var message = ex.getMessage();

}

In the above script at line number 5 I want to read the value from incident table, short description field(I tried with current.short_description but it does work for me).I want to get the clearTextValue using getNodeText method and assign it to resultText variable.

Can any one help in resolving above Query?

Earlier I use to use below script(REST) and it works fine for me.Not with Helsinki I am not able to get the exact result what I am expected to get:

In variable section I use to pass:

applicationName=ven011,fieldName=current.description,clearTextValue=${current.short_description}

try

  {

var jsonString=activity.output;

var xmlDoc = new XMLDocument2();

xmlDoc.parseXML(jsonString);

var resultText = xmlDoc.getNodeText('//clearTextValue');

current.description = resultText ;

current.update();

}

catch(ex)

{

  var message = ex.getMessage();

}

Message was edited by: lokesh vakare

4 REPLIES 4

Chuck Tomasi
Tera Patron

Hi Lokesh,



Where are you running this script from? If you run it from a business rule on the incident table, then current.short_description will give you what you need.



s.setStringParameter('field.fieldName', current.short_description);



Unless, you are asking to literally use the incident.short_description as a definition to table and field name to get a value? If that's the case, you could just parse it.



var s = 'incident.short_description';


var tableName = s.split('.')[0];


var fieldName = s.split('.')[1];



Then you can use a GlideRecord query on tableName to retrieve the value of fieldName. This is a great place to use getValue(fieldName), by the way. The big question is WHICH incident record do you want?


ctomasi: I am running this script from workFlow.I created workflow to run om Incident Table.Then in the soap message in sensor section I am passing above script.Before in the variable section I use clearTextValue=${current.short_description} and it use to read short description value from incident table.But from helsinki if i use the same script it does work for me.


Have you tried



clearTextValue = current.short_description;



in the sensor script instead of ${current.short_description}


ctomasi:Yes, I have tried with clearTextValue = current.short_description; but still no luck.