Flow Designer - Check if user has role

JordanDR
Tera Contributor

Working on a flow to unassign tickets from users with a specific role once they're deactivated.

 

I want to put in a check for a specific role so I'm doing a lookup record on the sys_user_has_role table, but unsure how to proceed to check if they actually have a role, and then using the status of that check in an if statement to update those records

 

Any suggestions would be helpful.

 

Thanks!

1 ACCEPTED SOLUTION

Hi @JordanDR,

 

If that's the case, I am assuming the trigger will be a user record.

e.g.

JamesChun_0-1714682172436.png

 

If so, the script can be something like:

var user = GlideUser().getUser(fd_data.trigger.current.user_name);
return user.hasRole('itil');

View solution in original post

3 REPLIES 3

James Chun
Kilo Patron

Hi @JordanDR,

 

Try the below:

  • Create a True/False type Flow Variable

JamesChun_0-1714597959223.png

  • Use Set Flow Variables Flow logic to set the variable via some script

JamesChun_1-1714598014665.png

  • Use the IF Flow logic to validate if the variable is True or False

JamesChun_2-1714598047855.png

 

Cheers

Hey James, 

Thanks for this! For this logic how would I get it to check the specific user? The trigger for the flow is if someone from a specific department is switched to inactive.

 

 

Hi @JordanDR,

 

If that's the case, I am assuming the trigger will be a user record.

e.g.

JamesChun_0-1714682172436.png

 

If so, the script can be something like:

var user = GlideUser().getUser(fd_data.trigger.current.user_name);
return user.hasRole('itil');