How to delete multiple records through Flow Designer?

Ankita Kolhe
Tera Contributor

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

6 REPLIES 6

Danish Bhairag2
Tera Sage
Tera Sage

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

 

Tai Vu
Kilo Patron
Kilo Patron

Hi @Ankita Kolhe 

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.

TaiVu_0-1701066559178.png

TaiVu_1-1701066566498.png

 

Cheers,

Tai Vu

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

Hi @Ankita Kolhe 

Okay. There you go!

1. Create new Flow Action

TaiVu_0-1701070599465.png

2. Add the Script step with the following code.

TaiVu_1-1701070624294.png

(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