- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2019 07:41 AM
We use an LDAP data source to populate users, groups, and group memberships. We have identified that the sys_user_grmember table has duplicate entries. For example, if user A should belong to group X, there may be more than 1 A/X entry in the sys_user_grmember list, making the group member list appear longer than necessary. This does not happen often. I will investigate the root cause separately. In the meantime, I need to remove the duplicates.
The https://community.servicenow.com/community?id=community_question&sys_id=91864725db1cdbc01dcaf3231f9619d9&view_source=searchResult posting is helpful but I want to find duplicate records in the source table and remove them.
How is an effective method to find those duplicate entries in a ServiceNow table given a set of criteria?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2019 07:52 AM
You can probably use something like this. We were getting users with duplicate email because of multiple sources of records and we used this script to be able to find them.
var userGr = new GlideAggregate('sys_user'); // replace with your table name
userGr.groupBy('email'); // field on which you want to find duplicate
userGr.addHaving('COUNT', '>', 1);
userGr.query();
while(userGr.next()){
gs.print(userGr.email); // adjust field name as per your table
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2024 09:32 AM
Did you find the root cause of this issue?
Thanks, T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2024 08:37 AM
For us, it was because we had some scripts that had an .insert in them and it would not check to see if they were already a member of the group before running the script to add them.