- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 01:22 AM
Hi All, Here is my server side script in widget to fetch records an remove duplicates.
data.arr=[];
var item=new GlideRecord('sc_req_item');
item.addEncodedQuery('opened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe');
item.query();
while(item.next()){
data.arr.push(item.cat_item.name.toString());
}
var arrayUtil = new ArrayUtil();
data.arr= arrayUtil.unique(data.arr);
console.log(data.arr);
This script works perfect in Global application. But in scoped application am getting error as ArrayUtil undefined, maybe missing global qualifier .
Still ArrayUtil works fine ,only issue is throwing error.
Any Suggestion to fix it please.
Thanks!
Sindhu K B
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 02:40 AM
Hi,
for using ArrayUtil in scoped app; please use this
var arrayUtil = new global.ArrayUtil();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 01:51 AM
check if this might help you to fix:
https://hi.service-now.com/kb_view.do?sysparm_article=KB0635929
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 02:40 AM
Hi,
for using ArrayUtil in scoped app; please use this
var arrayUtil = new global.ArrayUtil();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 03:21 AM
Hello Sana,
Calling a Global Script from Another Application Scope: A custom application can call a global script include that is public. For example, the ArrayUtils script include is in the global scope and must be fully qualified when accessing its functions:
<source lang="javascript"> var switches = new global.ArrayUtil(); switches.contains(ary, item); </source>
Minor modification to the script shared by Alberto.
dataArr=[];
var item=new GlideRecord('sc_req_item');
item.addEncodedQuery('opened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe');
item.query();
while(item.next()){
dataArr.push(item.cat_item.name.toString());
}
var arrayUtil = new global.ArrayUtil();
var data = arrayUtil.unique(dataArr);
console.log(data);
- Pradeep Sharma