How to automatically remove a user who is inactive from all roles and groups automatically?

Lauren Martinez
Kilo Explorer

I do not want to delete the user record from the sys_user table, just remove the associated roles.
Example, removing ITIL. 
I know I could have a scheduled job, with a script. I am not a developer so any assistance would be appreciated. I was trying to do this function with no code in flow designer but it would not allow me to dot walk to the roles action. Also, could apply via Business rule but also would need a script. Unless there is a glide reference that could be applied within the action field. 

 

Thanks for your help! 

6 REPLIES 6

Willem
Giga Sage
Giga Sage

Hi @Laur I have described the steps to create a Flow here:

https://community.servicenow.com/community?id=community_question&sys_id=71d742dedb9ed0149e691ea66896...

 

The steps:

Roles should be assigned to the group. Removing the user from the group results in the roles being removed. If you have set it up property, if not, set up properly first.

For workflow you can have the Trigger being scheduled:

find_real_file.png

Look up the users:

find_real_file.png

 

Find the groups the user is in:

find_real_file.png

 

For each of the found records we delete:

find_real_file.png

 

 

add the same for Group members Records but then for the Roles table: "sys_user_has_role":

find_real_file.png

Total flow is then:

find_real_file.png

 

 

HI,

 

I tried the same steps for my req of removing roles and groups for a user after 14days from the deactivation.

Getting the below result. Not updating all the records.

KarunThej_0-1721365676439.png

could you please help me on this ?

 

Thanks