
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 10:59 AM
Hi All
How can we call script include a function to another script include?
I have one script include function- "countKBArticle: function()" and need to call this function in the new script include but not sure how to call.
Regards,
Priya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 09:58 PM
Hello Priya,
1. You can call script include from another script include as below:
var osi = new otherScriptInclude();
osi.otherScriptIncludeFunction();
2. Way to call script include from Business rule, workflow activity or or from server side script:
var osi = new ScriptIncludeName();
osi.scriptIncludeFunction();
3. Way to call script include from client script, Catalog Client Script or UI policies
var deptName = g_form.getValue('department');
var si =new GlideAjax('ScriptIncludeName');
si.addParam('sysparm_name','scriptIncludeFunction'); // you need to use sysparm_name for calling function
si.addParam('sysparm_dept',deptName); // you can add any parameter here in place of sysparm_dept. like sys_dept
si.getXML(setDepartmentHead);
function setDepartmentHead(response){
var deptHead = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('u_department_head',deptHead);
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 11:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 11:32 AM
Hi Priya,
Please use the below method.
Script Include 1:
Name: MySI
getDemo: function()
{
gs.log("getDemo");
}
Script Include 2:
Name: MySITest
getDemoTest: function()
{
var obj = new MySI(); //Create an object of Script include
obj.getDemo(); //Call the function using the object of script include.
}
Output:
LOG: getDemo
Regards
Santosh Poudel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 12:02 PM
HI Priya
var a = new otherScriptInclude();
a.otherScriptIncludeFunction();
Please replace your ScriptInclude name
Thanks and Regards
Dilip Puligilla
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2019 09:58 PM
Hello Priya,
1. You can call script include from another script include as below:
var osi = new otherScriptInclude();
osi.otherScriptIncludeFunction();
2. Way to call script include from Business rule, workflow activity or or from server side script:
var osi = new ScriptIncludeName();
osi.scriptIncludeFunction();
3. Way to call script include from client script, Catalog Client Script or UI policies
var deptName = g_form.getValue('department');
var si =new GlideAjax('ScriptIncludeName');
si.addParam('sysparm_name','scriptIncludeFunction'); // you need to use sysparm_name for calling function
si.addParam('sysparm_dept',deptName); // you can add any parameter here in place of sysparm_dept. like sys_dept
si.getXML(setDepartmentHead);
function setDepartmentHead(response){
var deptHead = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('u_department_head',deptHead);
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade