- 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 06:11 AM
In ServiceNow, you can call a Script Include from a client script primarily using GlideAjax. Here are the main steps:
Create a Script Include: Ensure it is marked as client-callable.
Use GlideAjax in Client Script: Instantiate GlideAjax and pass the Script Include name and parameters.
Handle the Response: Use a callback function to process the response from the Script Include.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 09:46 AM
You can you script include in Multiple Ways in ServiceNow
1. GlideAjax
2. GlideRecord (server side)
3.Client Script
4.UI Actions
Should my answer prove to be helpful, kindly mark it as such by clicking "Accept as Solution" and "Helpful."
Regards,
Manikanta. Kota
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2024 11:13 PM
Please refer the link it may helps to you
Refer:
GlideAjax | ServiceNow Developers
Script Includes | ServiceNow Developers
If you found my answer helpful, please give it a like and mark it as the accepted solution.
Regards,
Sai Krishna