gs.hasRoleExactly('itil') is returning undefined

Sachin G K1
Kilo Sage

Hi All,

gs.hasRoleExactly('itil'), is returning undefined. But gs.hasRole('itil') is returning true please help.

SachinGK1_0-1709621853034.png

SachinGK1_1-1709621888260.png

 

12 REPLIES 12

Rakshit Adgaon1
Tera Contributor

There is no function gs.hasRoleExactly() in Glide System API. Glide System API has gs.hasRole() function available so it shows true. 

hasRoleExactly() function is available in g_user client side API.

Hi @Rakshit Adgaon1 

 

No do we have it in GlideSystem as well, i had used it recently.

you can also have look on below thread:

https://www.servicenow.com/community/virtual-agent-forum/hasrole-in-server-and-client/m-p/2843062/pa...

Harish Bainsla
Tera Sage
Tera Sage

Hi check below link for better understanding

  • gs.hasRole('itil'): This function checks if the current user has any of the roles listed, including "itil" and potentially others. It returns true if the user has at least one of the listed roles, including "admin" which grants access to most functionalities.

  • gs.hasRoleExactly('itil'): This function checks if the current user has only the "itil" role and no other roles. It returns true only if the user has "itil" and no additional roles.

https://blog.snowycode.com/post/user-object-cheat-sheet

 

I created sample user, with just itil role, its still returning undefined. And also please let me know if my understanding is correct regarding 'hasRole' and 'hasRoleExactly'.

1. hasRole('itil'), return true if user has 'itil'/'admin' role.

2. hasRoleExactly('itil'), return true if user has 'itil' role and also some other roles but not admin role.