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

paul_mcnamara
Giga Expert

The simplest way would be a hidden field set by the client script and then consumed by the business rule.


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/


You are marvelous!!!!! Thank you....


Hi,



Can you please mark answer as correct



Regards,


Solutioner


Logo.png


Enhance Knowledge NOW@ www.solutioningnow.com


http://www.solutioningnow.com/