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

It won't work on Script include. 

 

Rather try

 

var roles = gs.getUser().getUserByID().getRoles()+ '').split(',');

for(var i=0; i<roles.length; i++){

if(roles[i] == role ) return true;

 

}

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Hi @Sohail Khilji 

SachinGK1_0-1709640286875.png

I tried as you suggested, Line 7 is only returning "taxonomy_admin" and the in above script 'if' condition evaluated to 'false' else part executed.

Mark Manders
Mega Patron

This should help in your understanding: https://www.servicenow.com/community/itsm-articles/uses-of-hasrole-methods-client-and-server-side/ta...

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark