Flow duplicating users in a group

ClareM
Tera Expert

Hi,

 

I've updated my post with screenshots to provide more details

 

I've created a flow that runs on an approver table when a record is created or updated. If the approver field changes it checks if the approver is in the approver group and if not, adds them.

 

The issue is if multiple records are updated at the same time, the approver gets added to the group multiple times.

 

Is there a way to prevent this? I wondered if using a queue would solve the issue? I'm not sure how queues work in SNow.

 

Flow

ClareM_0-1750764985707.png

Sub flow - checks if user exists in group before adding

ClareM_1-1750765029287.png

Users updated in bulk in list edit view are added multiple times

ClareM_2-1750765175870.png

 

 

Thanks,

 

Clare

10 REPLIES 10

@ClareM 

try with business rule and if it still doesn't work then may be we don't have an approach yet.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@ClareM 

try using script step in your subflow and use GlideRecord to check if user+group combination already present

var userId = /* your user sys_id */; // pass this as input to subflow
var groupId = /* your group sys_id */;  // pass this as input to subflow
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.addQuery('group', groupId);
gr.query();
if (!gr.hasNext()) {
    var newGr = new GlideRecord('sys_user_grmember');
    newGr.initialize();
    newGr.user = userId;
    newGr.group = groupId;
    newGr.insert();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

SANDEEP DUTTA
Tera Patron
Tera Patron

Hi @ClareM ,

You mean to say you are changing the Approver regularly?

 

Thanks,
Sandeep Dutta

Please mark the answer correct & Helpful, if i could help you.

Hi Sandeep,

Yes, the approvers change regularly so we use various tables, cost centre etc. and I created flows to handle the assignment of the approver role.

I've updated my post with screenshots of the flows for further information

Thanks, Clare

Aniket Chavan
Tera Sage
Tera Sage

Hello @ClareM ,

Since you haven’t included screenshots or details of the flow setup, it's a bit tricky to give an exact solution—but based on what you described, one thing you can try is adding a check before adding the user to the group.

You can use a "Lookup Record" action on the sys_user_grmember table (that’s where group memberships are stored) and filter it by the user and the group. Use data pills to dynamically pass the approver and the group from your flow data.

Then, wrap your "Add to group" logic inside an "If" condition—only proceed to add the user if the lookup returns no matching records (i.e., the user is not already in the group).

This should help avoid duplicates even when multiple records are being updated around the same time.

If possible, feel free to share a screenshot of your flow setup—happy to take a closer look and suggest more precise tweaks!

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.


Regards,
Aniket