
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2019 04:38 AM
Hi all,
I have a client-callable script include in my instance. A function within this script accepts client parameters [this.getParameter('sysparm_sys_id')].
Now to reduce code redundancy, I would like to call the same function from server-side (business rule).
How to make this client-callable script-include function accept parameters and get utilized from server-side as well?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2019 04:46 AM
Hi, found the solution!
There is a one-line script to make a client-callable script-include function server-side accepted.
Add server type parameters to the function of script include:
getIncidents: function(problemId){
Now within the function use the below code line:
var probSysId = JSUtil.nil(problemId) ? this.getParameter('sysparm_sys_id') : problemId;
This way the function can accept parameters and can be called from both client & server side.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2019 04:41 AM
you can call script include from business rule like below:
var ga = new ScriptIncludeName.functionName(current.caller_id,current.assignment_group); // pass parameters you want to pass
OR
var ga= new ScriptIncludeName();
ga.functionName(current.caller_id,current.assignment_group);
Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2019 04:46 AM
Hi, found the solution!
There is a one-line script to make a client-callable script-include function server-side accepted.
Add server type parameters to the function of script include:
getIncidents: function(problemId){
Now within the function use the below code line:
var probSysId = JSUtil.nil(problemId) ? this.getParameter('sysparm_sys_id') : problemId;
This way the function can accept parameters and can be called from both client & server side.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2020 10:51 AM
Thanks, this has help me a lot. Will allow me to re-use scripts.
however, I had to do this instead, because JSUtil is not available for my Script include.
var probSysId = "";
if (typeof problemId !== 'undefined') {
probSysId = problemId ;
} else {
probSysId = this.getParameter("sysparm_sys_id");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2021 10:37 AM
Hi Benoit,
I'm also having the same requirement.
Could you please let me understand above code?
I'm not able to get it.
Thanks,
Ankita