UI action Condition based on Opened_by's roles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2022 05:07 PM
I am working to create a condition on a UI to only show if the 'opened_by' has a certain role. It does not matter who the current user is that is looking at the ticket it matters who opened it. Is the best way to do this a script include?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2022 06:33 PM
Hi you can check the condition in UI Action condition builder
gs.hasRole('your role name goes here') && (current.opened_by== gs.getUserID())// it should match both role and openedby user
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 07:19 AM
Isn't this looking at the currently logged in user's role and then making sure the currently logged in user is the same as the opened by?
The requirement doesn't need to look at the currently logged in user at all. All it needs to do if see if the ticket was opened by a user with a particular role and if it was show a UI action for everyone in the system with access to that ticket.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 07:25 AM
Hi Marksh11
Try this
gs.getUser().getUserByID(current.opened_by).hasRole('role_name');
I didn't tested this out, if this doesnt work then you can call script include from here
let us know if you need help with logic.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 07:36 AM
Thanks for the response -- i tried that and it seems to be failing as well. It just displays no matter what even though the opened_by does not have the role indicated.