ArrayUtil unique not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 01:12 PM
I have this code that I am using in a fix script and I am trying to get an unique array. The ArrayUtils does not work. Can someone tell me whats wrong with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 01:21 PM
When you push to the array, be sure to pass in the value with a .toString(). I.e.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2023 01:53 PM
Only one sys_id is being displayed. Any idea why?
Here is the remainder of the script:
// Remove existing auths assigned to the user
var existingAuthsGr = new GlideRecord('auth table');
existingAuthsGr.addQuery('u_user', userGr.sys_id);
existingAuthsGr.deleteMultiple();
// Assign the unique roles to the user
for (var i = 0; i < finAuths.length; i++) {
var newAuth = new GlideRecord('auth table');
newAuth.initialize();
newAuth.u_user = userGr.sys_id;
newAuth.u_user_authorization = finAuths[i];
newAuth.insert();
}
}