How to add role to the user by using flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 01:05 AM
Create a catalog item - with 2 variables
one variable to get the requested for user, one to get the role
once the request is submitted, should ask for approval from requested user's manager
If approved assign the role to the user, if reject send a email to notify the rejection
for Ex:- newuser Role :- admin if we submit the record then it should add the role in roles table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 01:57 AM
Hello,
You can use the 'Create Record' action in the flow designer and add the user along with the role selected to 'sys_user_has_role' table. Prior to which you have to evaluate the approval condition.
Regards
ServiceNow Consultant
United Kingdom

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2022 04:08 AM
Flow Designer Steps -
Step 1 - Get Catalog Variables.
Step 2 - Ask For Approval - Approval for Requested Fors Manager
Step 3 - If Approval.State = Approved
Step 4 - Create Record on sys_user_has_role table
Mark as helpful if this works for you,
Thanks
Chinmay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 08:38 PM
Hi @Chinmay Tawade1 ,
Similarly i am trying for roles to be added to group,. Role is created as list collector variable, but lookup is not working for list collector what should i do.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 10:20 PM - edited 11-27-2023 10:23 PM
First thing is - a record must be created on sys_group_has_role table for each role.
so thats the reason you cannot add multiple roles(list collector) into one record.
I have created a flow and custom action to add roles to group.
Catalog item with variables - Group(reference) and Roles(List Collector)
Below is the flow
Step 1 - Get catalog variables
Step 2 - Custom action to convert list collector roles value to array of string (bcause we cannot loop though list collector value so need to convert it to array of string)
Step 3 - For each loop on Array of Roles from step 2 custom action
Step 4 - create sys_group_has_role record for each list collector group
In this way you will first need to process/convert the list collector roles value to Array and then apply for each on that array, and create record for each role. You cannot add all roles to one group role record, you need to create individual record for each role.
Please Mark as helpful, if this resolves your problem.
Thanks,
ServiceNow Developer