- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 12:01 PM
I have an array of sys ids based on a query, but the array has duplicates in it and I'm not able to get unique values using ArrayUtil.unique() and I don't know why.
The query is working as I expect, multiple divisions can have the same department.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 01:56 PM
Hi @gjz,
You can use the GlideAggregate to group the query together, so you won't have to use the use the ArrayUtil.
e.g.
var myDept = [];
var eQuery = 'u_liaisonsLIKE' + '49f32c82dbd89340197c38ff9d9619e1';
var agg = new GlideAggregate('u_cmn_divisions');
agg.addEncodedQuery(eQuery);
agg.groupBy('u_department');
agg.query();
while(agg.next())
{
myDept.push(agg.getValue('u_department'));
}
Back to your script, try replacing myDept.push(d.u_department.sys_id); to
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 01:56 PM
Hi @gjz,
You can use the GlideAggregate to group the query together, so you won't have to use the use the ArrayUtil.
e.g.
var myDept = [];
var eQuery = 'u_liaisonsLIKE' + '49f32c82dbd89340197c38ff9d9619e1';
var agg = new GlideAggregate('u_cmn_divisions');
agg.addEncodedQuery(eQuery);
agg.groupBy('u_department');
agg.query();
while(agg.next())
{
myDept.push(agg.getValue('u_department'));
}
Back to your script, try replacing myDept.push(d.u_department.sys_id); to
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2024 03:33 PM
Works like a charm! Thanks!