How do I add a user to a role in Flow Designer?

Jesse Walter
Giga Contributor

I have a flow that I created that automatically creates a new user record in ServiceNow when a certain task is created. This works fine, however I want to now add the user to a role and it is not functioning.

I grab the User Record created in the designer (which, again, has been successfully created), then try to add Roles. I am using the sys_id of the role in which I would like to add. However, the role never gets added.

Has anybody accomplished this in the past?

1 ACCEPTED SOLUTION

Community Alums
Not applicable

You can't add a role like that. 

If you really want to add a role you need to add an entry to the sys_user_has_role table, but you should really add the user to a group (sys_user_grmember) and let that group inherit the role you're trying to give out. 

View solution in original post

6 REPLIES 6

Community Alums
Not applicable

You can't add a role like that. 

If you really want to add a role you need to add an entry to the sys_user_has_role table, but you should really add the user to a group (sys_user_grmember) and let that group inherit the role you're trying to give out. 

I appreciate the response! I created a group that contains the role I want to add. When I attempt to update the user record with the group, "Group" is not an available field on the record. When I switch the table to sys_user_grmember, the "Record" field disappears, so I'm not exactly sure how to add the user to the group via Flow Designer unfortunately.

Community Alums
Not applicable
You don't update the user record at all ☺️. You need to create a record on the sys_user_grmember table. In there you create an entry with the user you want to add to the group, and the group you want to add them to. It's also worth checking they're not already in the group before you do that.

Community Alums
Not applicable

Here's a breakdown in screenshots (for this example "Hiring manager" is the person you want to put in the group, and "hiring group" is the group you want to put them in, it was the first catalog item I found with user and group details in :))

Edit: I've noticed an error in the first screenshot, but I've already deleted the demo flow - it should check both the user and the group!!

  1. find_real_file.png
  2. find_real_file.png
  3. find_real_file.png