How to delete multiple records through Flow Designer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2023 09:31 PM
Hi Community,
I have a variable named as 'Removed Members' (type-list collector) so when request gets submitted, it should remove users from that group.( it means to delete sys_user_grmember record where group is 'x' & user is 'y').
Example:-
Group: Group A
Removed Users- User A, User B
Can anyone please help how to delete multiple sys_user_grmember records with the help of flow designer?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2023 09:39 PM
Hi @Ankita Kolhe ,
U can create a custom action in ur flow designer n call that custom action in ur main flow. In the custom action u can write a script where u can use glide record to query n remove selected users from the group.
As an input to ur custom action u can take those list collector value.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2023 10:32 PM
As Danish's advise, you can create your own custom action with the input group and users to be removed.
Then query to the Group Member [sys_user_grmember] table, and use the API deleteMultiple.
deleteMultiple()
In the other hand, you can leverage the OOTB and a loop to achieve it.
Sample below.
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2023 11:31 PM
Hi @Tai Vu ,
Thanks for your response.
Could you please help me with custom 'Look up Records' action as I'm new to flow designer.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2023 11:39 PM
Okay. There you go!
1. Create new Flow Action
2. Add the Script step with the following code.
(function execute(inputs, outputs) {
var groupID = inputs.group_id;
var userIDs = inputs.user_ids;
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery('group', groupID);
grMember.addQuery('user', 'IN', userIDs);
grMember.query();
grMember.deleteMultiple();
})(inputs, outputs);
3. Call the custom Flow Action in your flow and drop the Group variable and the User variable into the parameter of the action.
Cheers,
Tai Vu