- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 03:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 04:04 AM - edited 09-30-2024 04:07 AM
Hi @Karthik_Yallam1 ,
There are actually two ways to achieve this:
1. Using GlideAjax: This is the most common approach.
- You create a GlideAjax object, specify the script include name, and call a function on the script include.
- The script include returns a result, which you can then process in the client script.
2. Using the g_form object:
- If the script include is specifically designed to work with forms, you can directly call its functions using the g_form object.
- This method is more efficient and can be used for simple interactions with form-related script includes.
Here's an example of each method:
Using GlideAjax:
var ga = new GlideAjax('MyScriptIncludeName');
ga.addParam('param1', 'value1');
ga.addParam('param2', 'value2');
ga.get();
ga.addCallback(function() {
var result = ga.getAnswer();
// Process the result
});
Using the g_form object:
var result = g_form.callServer('MyScriptIncludeName', 'myFunction', 'param1=value1¶m2=value2');
// Process the result
Choosing the right method:
- GlideAjax: Use this method for general-purpose script include calls and when you need to pass parameters or handle asynchronous responses.
- g_form object: Use this method for script includes that are specifically designed to work with forms and when you need to call functions directly from the client script.
===================================***************=========================================
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thanks & Regards,
Aditya
=====================================***********==========================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 03:51 AM
There is only one way that you can call script include in client script by using GlideAjax.
Please refer the below post: In how many methods we can call script include in ... - ServiceNow Community
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 04:04 AM - edited 09-30-2024 04:07 AM
Hi @Karthik_Yallam1 ,
There are actually two ways to achieve this:
1. Using GlideAjax: This is the most common approach.
- You create a GlideAjax object, specify the script include name, and call a function on the script include.
- The script include returns a result, which you can then process in the client script.
2. Using the g_form object:
- If the script include is specifically designed to work with forms, you can directly call its functions using the g_form object.
- This method is more efficient and can be used for simple interactions with form-related script includes.
Here's an example of each method:
Using GlideAjax:
var ga = new GlideAjax('MyScriptIncludeName');
ga.addParam('param1', 'value1');
ga.addParam('param2', 'value2');
ga.get();
ga.addCallback(function() {
var result = ga.getAnswer();
// Process the result
});
Using the g_form object:
var result = g_form.callServer('MyScriptIncludeName', 'myFunction', 'param1=value1¶m2=value2');
// Process the result
Choosing the right method:
- GlideAjax: Use this method for general-purpose script include calls and when you need to pass parameters or handle asynchronous responses.
- g_form object: Use this method for script includes that are specifically designed to work with forms and when you need to call functions directly from the client script.
===================================***************=========================================
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thanks & Regards,
Aditya
=====================================***********==========================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 04:29 AM
From a client script, the recommended way is to make use of GlideAjax. You can refer below posts to check how you can use it :
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 04:31 AM
@Karthik_Yallam1 The most comman way to call a script include from client script is using GlideAjax. For more information on GlideAjax please refer to https://developer.servicenow.com/dev.do#!/reference/api/utah/client/c_GlideAjaxAPI