Access current object in script include

Kim Kronborg
Kilo Expert

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

7 REPLIES 7

That's very odd because I know I've done things like this:



javascript:'sys_class_name=' + current.something.somethingelse;


Aakash Shah4
Tera Guru

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.


Hi Aakash,



Please see my reply to Chuck



Thanks