- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 05:04 AM
As we know, to access server side value we use make use object "current" in Business Rule. Similarly can we use object "current" in "Script Include". If not what are other ways to access server side value in script include except "GlideRecord".
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 05:12 AM
As Mohith suggested above, to gain deeper understanding you can refer to below article:
Ref link:
Can Script Includes Use the "current" Variable?
The correct way to access the “current” object in a Script Include, is to pass it into the function you’re calling (and preferably, to use a variable name within the method other than “current”).
Note: Keep in mind that when handling objects in JavaScript, you’re passing by reference, not by value. This basically means that anything that you do to the object in the Script Include, will also happen to that object in the Business Rule - even if your SI method doesn’t return anything!
Since this is the “short” solution, I’ll spare you the explanation of pass-by-reference (PBR). If you want to know more about it - and you should - you can read more in my article on the subject, here.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 05:07 AM
Hello
yes you can use current object in a script include
try calling a script include from a BR and lets say if your script is on incident table
and you write current.number you will get the incident number
HERE IS ONE EXAMPLE
Refer to this below link for detailed explanation
https://snprotips.com/blog/2019/12/18/can-script-includes-use-the-current-variable
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 06:01 AM
Hi Mohith,
Script include function:
getdetails: function() {
return gs.addInfoMessage(current.caller_id.email);
},
i accessed the "current" in script include as you suggested and it worked. But suppose we want to pass this to client script how to do this?
I tried access it in client script like below but didn't work:
Script Include:
getdetails: function() {
return current.caller_id.email;
}
Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var ga=new GlideAjax("AbstractAjaxProcessor");
ga.addParam("sysparm_name","getdetails");
ga.getXML(res);
function res(response){
var answer=response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage(answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 06:07 AM
Hello
Make sure our script include is client callable
and i noticed that there was typo error in "return" keyword so i corrected it .
it should work i guess now give a try with below scripts
script include :
getdetails: function() {
return current.caller_id.email.toString();
}
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var ga=new GlideAjax("AbstractAjaxProcessor");
ga.addParam("sysparm_name","getdetails");
ga.getXML(res);
}
function res(response){
var value=response.responseXML.documentElement.getAttribute("answer");
g_form.addInfoMessage(value);
}
PLEASE MARK MY ANSWER CORRECT IF IT HELPS YOU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2022 06:20 AM