How do I determine a user in a script, when the user has no roles?

Jacob Saaby Ni1
Giga Expert

Hi everyone.

When creating view rules, I'd normally go for hasRole to specify a view for an ITIL user for example.

But, how do I target users who have no roles, in my scripts?

Is it hasRole('NULL'), hasRole($null) or perhaps hasRole('')?

Or is it better to use a fourth way?

1 ACCEPTED SOLUTION

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Here:



how to check for null roles using gs.hasRole() function



gs.getUser().getUserRoles().toArray().length==0 //this means current user does not have any roles.


View solution in original post

5 REPLIES 5

Awesome, thanks!