- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:08 AM
I'm trying to run a server script I created in a script include using "Glide Ajax" in a client script.
<Client script>
function test() {
var inputVal = confirm('Do you want to run the process?');
if (inputVal) {
var ga = new GlideAjax('Server_script_name');
ga.addParam('parameter1',g_form.getUniqueValue());
ga.getXML();
}
}
<Script include>
var Server_script_name= Class.create();
Server_script_name.prototype = Object.extendsObject(AbstractAjaxProcessor, {
run_script: function() {
var tmp_msg = this.getParameter('parameter1');
gs.addInfoMessage(tmp_msg );
}
});
How can I pass a value from a client script to another script?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:29 AM
Also you need to update script include part at the end.
missing below line:
type: 'Server_script_name'
Your Script include should be like below:
var Server_script_name= Class.create();
Server_script_name.prototype = Object.extendsObject(AbstractAjaxProcessor, {
run_script: function() {
var tmp_msg = this.getParameter('parameter1');
gs.info(tmp_msg);
gs.addInfoMessage(tmp_msg );
},
type: 'Server_script_name'
});
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:11 AM
Hi,
Update the script include part like below:
function test() {
var inputVal = confirm('Do you want to run the process?');
if (inputVal) {
var ga = new GlideAjax('Server_script_name');
ga.addParam('sysparm_name','run_script'); // call server side function using this line, it is mandatory
ga.addParam('parameter1',g_form.getUniqueValue());
ga.getXML();
}
}
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:29 AM
Also you need to update script include part at the end.
missing below line:
type: 'Server_script_name'
Your Script include should be like below:
var Server_script_name= Class.create();
Server_script_name.prototype = Object.extendsObject(AbstractAjaxProcessor, {
run_script: function() {
var tmp_msg = this.getParameter('parameter1');
gs.info(tmp_msg);
gs.addInfoMessage(tmp_msg );
},
type: 'Server_script_name'
});
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:12 AM
Hi,
Alos, please use check below link to learn more about GlideAjax functionality.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 02:34 AM
Hi,
I would suggest you to go through the ServiceNow documentation around GlideAjax
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader