Remove User Group Roles if not logged in last 35 Days - Using Only Flow Designer

Piyush Kumar
Kilo Contributor

Hi,

I have a requirement - 

By Using Only Flow Designer remove all user roles and groups (except snc_internal) of a user if the last login time is 35 days ago.

 

Need to trigger daily and check for users.

Regards,

Piyush Kumar

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

Hi Piyush,

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

View solution in original post

14 REPLIES 14

Below I have created the flow as you showed above but getting an error while executing

find_real_file.png

 

 

Error Screenshot

 

find_real_file.png

 

Not sure if something has changed on the ServiceNow side since your great solution but when I test it on my end, it doesn't run the delete action.

Sudhanshu Talw1
Tera Guru

Hi,

Simply trigger of the flow everyday at a specific time.

Lookup all user records which does not have logged into the system last 35 days.

For each user record

1.lookup all the roles "sys_user_has_role" in this table except for snc_internal. Delete them

2. Lookup all records in the sys_user_grmember table. Delete all records.

 

Thanks

Sudhanshu

 

 

 

Willem
Giga Sage
Giga Sage

Hi Piyush,

Hope you are doing well.

Is your question resolved? Or do we need to follow-up on this?

Please mark this answer as correct if it solves your question. This will help others who are looking for a similar solution. Also marking this answer as correct takes the post of the unsolved list.

 

Feel free to mark answers as Helpful if you think they are.


Thanks.

Kind regards,

Willem