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

Super helpful! This worked! Thank you so much for explaining this to me!

Balaji Jagannat
Kilo Guru

Hi Jesse - in addition to adding the user role either to 'sys_user_has_role' or by adding user to the 'Groups' table, ensure your flow is set with proper 'run as'. 

 

For instance, if the flow is set to run as 'User who initiates session', then that user should have enough permission to assign/manage roles.