Once a group is deactivated, all the roles and members of the groups have to be removed

minigupta
Kilo Contributor

Once a group is deactivated, all the roles and members of the groups have to be removed

1 ACCEPTED SOLUTION

ghsrikanth
Tera Guru

You can write an After Business rule on sys_user_group


which has the condition


current.active.changes() && !current.active


in the script section


//roles of groups gets stored in the sys_group_has_role


var grGrpRole = new GlideRecord('sys_group_has_role');


grGrpRole.addQuery('group',current.sys_id);


grGrpRole.query();



grGrpRole.deleteMultiple();



//Users gets stored in the sys_user_grmember


var grGrpUser = new GlideRecord('sys_user_grmember');


grGrpUser.addQuery('group',current.sys_id);


grGrpUser.query();



grGrpUser.deleteMultiple();



Mark if it is correct or helpful, feedback is appreciated


View solution in original post

1 REPLY 1

ghsrikanth
Tera Guru

You can write an After Business rule on sys_user_group


which has the condition


current.active.changes() && !current.active


in the script section


//roles of groups gets stored in the sys_group_has_role


var grGrpRole = new GlideRecord('sys_group_has_role');


grGrpRole.addQuery('group',current.sys_id);


grGrpRole.query();



grGrpRole.deleteMultiple();



//Users gets stored in the sys_user_grmember


var grGrpUser = new GlideRecord('sys_user_grmember');


grGrpUser.addQuery('group',current.sys_id);


grGrpUser.query();



grGrpUser.deleteMultiple();



Mark if it is correct or helpful, feedback is appreciated