- 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:26 AM
Hi Sindhu,
you can use ArrayUtil in scope application, use the following code as example:
var res=[];
var changeArr=[];
var changeTask = new GlideRecord('change_task');
changeTask.addQuery('change_request', current.sys_id);
changeTask.query();
while (changeTask.next())
{
changeArr.push(changeTask.assignment_group.manager);
res.push(current.u_technical_approver_users=changeArr); //
}
var au = new ArrayUtil();
var newChangeArr = au.unique(changeArr);
var newRes = au.unique(res);
If I have answered your question, please mark my response as correct and/or helpful.
Thank you very much
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 01:33 AM
Thanks for your quick reply.please check my updated post.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 01:45 AM
Try this code please:
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 ArrayUtil();
var data = arrayUtil.unique(dataArr);
console.log(data);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2020 01:46 AM
ArrayUtil is working. But still it throws error.