How to pass two different functions from client side script to server side script by using glide Aja

Samara391
Kilo Contributor

How to pass two different functions from client side script to server side script by using glide Ajax?

By using onChange client script, I want to pass two functions & also have to get response from two different functions.

Please help me on this with syntax code.

 

 

Thanks in advance @Chuck @Sunil Mitkari @Sravan Kumar  @Bhavana Reddy V 

2 REPLIES 2

Vishal Birajdar
Giga Sage

Hi @Samara391 

 

You can take reference of below code :

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
       if (isLoading || newValue === '') {
       return;
       }

 

//Call to first function
var ga1 = new GlideAjax("test");
ga1.addParameter('sysparm_name','function1');
ga1.addParameter('sysparm_variable','variable1');
ga1.getXMLAnswer(firstCallBack);

 

//Call to second function
var ga1 = new GlideAjax("test");
ga1.addParameter('sysparm_name','function2');
ga1.addParameter('sysparm_variable','variable2');
ga1.getXMLAnswer(secondCallBack);

 

}

 

           // write callback functions here

          //First
          function firstCallBack(answer) {
         //Do your things
          }

         

          //Second 

          function secondCallBack(answer) {
         //Do your things
          }

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Tony Chatfield1
Kilo Patron

Hi, you could potentially call 1 function and pass in a parameter that defined if the function called another function, rolling the results of the second function into the result returned to client side by first function.