ArrayUtil undefined, maybe missing global qualifier

Thomas20
Giga Contributor

New to ServiceNow development. Trying to create a widget that counts the number of non-duplicate entries in a table. I wrote some code in the widget's Server Script.

Code (taken from https://docs.servicenow.com/bundle/newyork-application-development/page/app-store/dev_portal/API_ref...😞

    var arrayUtil = new ArrayUtil();
    var a1 = new Array("a", "b", "c", "c", "b");
    gs.print(arrayUtil.unique(a1));

Error Message: ArrayUtil undefined, maybe missing global qualifier

Not sure what I'm doing wrong. Am I putting the script in the right spot?

1 ACCEPTED SOLUTION

MrMuhammad
Giga Sage

Are you calling the ArrayUtil from scoped application? Then update below line as

var arrayUtil = new global.ArrayUtil();

Regards,
Muhammad

View solution in original post

3 REPLIES 3

MrMuhammad
Giga Sage

Are you calling the ArrayUtil from scoped application? Then update below line as

var arrayUtil = new global.ArrayUtil();

Regards,
Muhammad

Hi Thomas,

 

It would be great if you comeback and mark my response ACCEPTED & HELPFUL if your question has been answered. So that this can be displayed at the top of the list and others with same question can be benefited by this.


Thanks & Regards,
Sharjeel

 

 

Regards,
Muhammad

MrMuhammad
Giga Sage

Adding a nice article on ArrayUtils usage in global vs scoped application and its method with example scripts. Hopefully, this will help future readers. 

https://community.servicenow.com/community?id=community_article&sys_id=d5d43229db47d0943daa1ea668961...

Please don't forget to mark that helpful and drop your feedback in the comment section this helps us stay motivated.

Regards,
Muhammad