- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 09:49 AM
Hi All,
I am working in scoped application. i have an array which has the duplicate user sys ids. How can I remove duplicate values and get unique values..?
Thanks,
Kumar
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 10:05 AM
Array Utils is Script Include and number of functions for array manipulation
So use Array Utils for requirement like below-
var gr = new GlideRecord('sysapproval_approver');
var approver = gr.approver.getRefRecord();
gr.addQuery('state', 'requested');
gr.addQuery('sysapproval.sys_class_name','sc_request');
gr.addQuery(approver.notification,'2');
gr.query();
var userArray = [];
var arrayUtil = new ArrayUtil();
while (gr.next()) {
if(arrayUtil.contains(userArray,gr.approver.toString())) {
continue;
}
userArray.push(gr.approver.toString());
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 10:05 AM
Array Utils is Script Include and number of functions for array manipulation
So use Array Utils for requirement like below-
var gr = new GlideRecord('sysapproval_approver');
var approver = gr.approver.getRefRecord();
gr.addQuery('state', 'requested');
gr.addQuery('sysapproval.sys_class_name','sc_request');
gr.addQuery(approver.notification,'2');
gr.query();
var userArray = [];
var arrayUtil = new ArrayUtil();
while (gr.next()) {
if(arrayUtil.contains(userArray,gr.approver.toString())) {
continue;
}
userArray.push(gr.approver.toString());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2018 02:57 AM
In short following code will work in scoped application to get unique values in an array:
var allLocations = [<a>,<b>,<c>,<a>,<d>];
var arrayUtil = new global.ArrayUtil();
allLocations = arrayUtil.unique(allLocations);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2022 03:24 AM