
- 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
‎07-16-2024 11:36 AM
Here is a whole solution:
//You call the client callable Script Include the same way as the server-side Script include
var scriptIncludeShortName = new ScriptIncludName();
//Then you call the Script Include function by dotwolking to his name
var valueReturnedBySIFunction = scriptIncludeShortName.theFunctionName(parameterOne, parameterTwo);
//Then you need to change the function declaration in the Script Include in a way that it can access values also from the server-side call
//That means:
//You need to change it from this:
functionName: function() {
var firstParameter = this.getParameter("sysparm_parameter_one");
var secondParameter = this.getParameter("sysparm_parameter_two");
...
}
// To this:
functionName: function(parameterOne, parameterTwo) {
var firstParameter = parameterOne || this.getParameter("sysparm_parameter_one");
var secondParameter = parameterTwo || this.getParameter("sysparm_parameter_two");
...
}
I hope that this will be helpful to someone.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2019 04:46 AM
For Scoped Applications, use the below
var abc = new global.ScriptIncludename();
var result = abc.ScriptIncludeFunctionName(current.yourparameter);
Please mark the answer as Correct and Helpful, if it works for you.
Regards,
Sajilal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2024 11:45 AM - edited ‎07-16-2024 11:46 AM
I believe @Earl Duque had a detailed blog post on this that he recently moved to Community somewhere. Look for that.
Edit: Here it is https://www.servicenow.com/community/developer-advocate-blog/client-callable-and-server-callable-scr...