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 set Dynamic value using variable in Soap Message?

lvakare
Kilo Contributor

I am using Soap Message in workFlow in Sensor Script i am using "var jsonString=activity.output;" and in variables I am passing "clearTextValue=Testdata" and it is taking "Testdata" and it display value to corresponding field but i want Dynamically generated value to set to activity instead of hardcoding value in variable as mentioned above.can any one suggest how to do this?

Here i will get the dynamic data in "sc_request.description field" and I want to send that data as setParameterValue instead of hardcoding in variable and then I want to perform activity.ouptput operation.How to do this?

2 REPLIES 2

lvakare
Kilo Contributor

Using SoapMessage we basically set setStringparameter value using below script:



try


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


s.setStringParameter('clearTextValue', gr.description);


}


In the above script in gr.description I will get dynamic value from variables.Now   I want to set gr.description   to clearTextValue attribute using below script:


try


  {


//before getting Response using activity.output I want to setStringParameter value "gr.description" to activity.To use below script we pass parameter values using variables but in variables when I set clearTextValue=gr.description, then it is considering "gr.description" as text value instead of taking the value returned from gr.description.Can any one suggest how to do this?



var jsonString=activity.output;


}


lvakare
Kilo Contributor

After searching for long time in community I found Question 1: You can use the is similar issue what i have below is the question copied from the link:



In the Variables sections, the documentation indicates I need to define the string as "name1=value1, name2=value2", however, since this is a String, will it accept Glide/Javascript variables? For example, can I use "clearTextValue=gr.description"?


and i followed the solution given in the same link solution is pasted below:


You can use the ${...} templating syntax used elsewhere in the system to insert dynamic values, in this case it would be




  1. clearTextValue=${gr.description}  

but it is not reading dynamic value from this solution.Can any one suggest how to do this?