How to update the roles field with all the roles associated to the user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 03:53 PM
Hi All,
There is a field called roles on the sys_user table which is a list collector, Now we also have a table called sys_user_has_role table where all the roles associated to the user are stored.
Can someone provide me a fix script which can look at all the roles associated to a user and update the same to the roles field in the sys_user table which is a list collector?
How can this be implemented in a flow designer as well? If flow designer has a way to update the roles table with the roles added to the sys_user_has_roles table that would be awesome as well.
Please let me know in case anyone has a solution (Script) to this
Thanks,
Praveen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2023 12:07 AM
Hi,
Roles field is not list collector type, this is OOTB field of type "User Roles". I don't think we should be updating this field with roles from sys_user_has_role table.
There is an internal link between role and this field.
Try below link to check
https://yourinstance.service-now.com/sys_user_list.do?sysparm_query=roles=admin
Thanks and Regards,
Saurabh Gupta

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2023 01:03 AM - edited 09-09-2023 01:04 AM
Hi @User206787 ,
Please find below script. Though I would suggest you not to update the roles field of user table. There might be other scripts running on that field which may get impacted.
First Way:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2023 01:21 AM
Hi,
Like Saurabh already mentioned, you should not make changes to this OOB field Roles.
What are you trying to do? What is it you want to achieve? What issue are you trying to solve?