How to pass two different functions from client side script to server side script by using glide Aja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 10:28 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 07:54 PM
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
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2023 08:11 PM
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.