How to prevent duplicate records in sys_user_grmember?

AyushK889749193
Kilo Contributor

We are seeing duplicate records in the sys,user,grmember table where the same user is added to the same group multiple times. This usually happens due to automated scripts, Flow Designer actions, or integrations that add group members without checking existing membership first.

What is the recommended best practice in ServiceNow to prevent these duplicate user and group records from being created?

5 REPLIES 5

Matthew_13
Mega Sage

@AyushK889749193 - In ServiceNow, the best practice is to prevent duplicates before they’re created, not clean them up later. Always check if the user is already in the group before inserting, and back that up with a Before Insert business rule or a uniqueness constraint on user plus group. That way, scripts, flows, and integrations can’t accidentally add the same membership twice.

MJG