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.

Passing Value from Client Script to Business Rule

salvadormarchan
Kilo Guru

Hi All,

 

I have a variable editor at the Request Item table and the elements vary from one record to another (they start with "ni.VE"). I am able to retrieve these values via Label with this client-side code:

 

var labelList = document.getElementsByTagName('label');

var tempElem, tempName, tempID;

for (var i = 0; i < labelList.length; i++) {

    tempElem = labelList[i].firstChild;

    tempName = tempElem.data;

    tempID = new String(labelList[i].getAttribute('for'));

    if (tempID.indexOf("ni.VE") > -1) {

          alert(tempName + '\n' + tempID + '\n' + $(tempID).value);

    }

}

 

From wiki, g_scratchpad passes values from server-side to client-side.

 

Question: How do we pass values from client-side to server-side?

 

Thanks,

Dor

1 ACCEPTED SOLUTION

solutioningnow
Giga Guru

Hi Salvador,



I can understand that you are trying to pass the variables from client side to server side. Instead try the below script directly in a business rule to access the variables in the variable editor.



Script:


for (key in current.variables) {


          var v = current.variables[key];


          if(v.getGlideObject().getQuestion().getLabel() != '') {


                gs.addInfoMessage(v.getGlideObject().getQuestion().getLabel() + " = " + v.getDisplayValue() + "\n");  


          }


}



Try this and let me know the outcome!



Please mark answer as correct/helpful, if it was really helpful.



Regards,


Solutioner


Logo.png


Enhance Knowledge NOW@ www.solutioningnow.com


http://www.solutioningnow.com/


View solution in original post

8 REPLIES 8

Yes...I guess we need someone with admin rights to change the category of this post...(I don't see any link/button for accepting your reply.)


or a Moderator.....


Lawrence Eng, could you please help Salvador in marking my answer as correct?






I set the thread as a question and marked your reply as correct.