Access current object in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2017 06:46 AM
Hi,
Can somebody tell me what I'm doing wrong when I try to access the current object in my script include below.
I have a reference qual on a field that looks like this :
u_my_shopLIKEjavascript:GetShopsFromGroups(getMyGroups())[0];^EQ
and my script include looks like this :
function GetShopsFromGroups(groups) {
gs.log('Shop number = ' + current.u_shop_number);
}
but I get the following error :
org.mozilla.javascript.EcmaError: "current" is not defined.
Caused by error in Script Include: 'GetShopsFromGroups' at line 3
1: function GetShopsFromGroups(groups) {
2:
==> 3: gs.log('Shop number = ' + current.u_shop_number);
4:
5: }
Should I not be able to access the current object from my script include when I call the script include from a ref qual ?
According to this community article it should be possible : https://community.servicenow.com/thread/207784
/Kim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2017 07:30 AM
That's very odd because I know I've done things like this:
javascript:'sys_class_name=' + current.something.somethingelse;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2017 06:52 AM
Hi Kim,
As per the thread which you have posted.
There the current is being called from a Business rule which is running on an Incident table so current is getting the table name and accordingly the value
In your case you are using the reference qualifier which can be used in any table hence the current value is not defined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2017 07:05 AM
Hi Aakash,
Please see my reply to Chuck
Thanks