- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2020 09:56 AM
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?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2020 10:00 AM
Are you calling the ArrayUtil from scoped application? Then update below line as
var arrayUtil = new global.ArrayUtil();
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2020 10:00 AM
Are you calling the ArrayUtil from scoped application? Then update below line as
var arrayUtil = new global.ArrayUtil();
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2020 12:03 PM
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
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2022 12:48 AM
Adding a nice article on ArrayUtils usage in global vs scoped application and its method with example scripts. Hopefully, this will help future readers.
Please don't forget to mark that helpful and drop your feedback in the comment section this helps us stay motivated.
Muhammad