UI action Condition based on Opened_by's roles

Marskh11
Tera Guru

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? 

5 REPLIES 5

Harish KM
Kilo Patron
Kilo Patron

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

Regards
Harish

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. 

Voona Rohila
Kilo Patron
Kilo Patron

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

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.