Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

check if logged in user has end user role using client script

rishi4200
Giga Expert

Hi Friends,

Could someone please let me know, how can I check if logged in user has end user role using client script ?

THank you.

Rishi

6 REPLIES 6

madanm7786
Mega Guru

Hi Rishi,

Use hasRole(). This will return'TRUE' if the user is having any role else return 'FALSE'.

var usr = gs.getUser();
if(usr.hasRole())
{
gs.print("Yes");
}
else
{
gs.print("No");
}


Thanks,
Maddy

Hi Maddy,

Thanks for your quick response !

Do you think we can use gs.getUser() at client side ?

 

You'll need to use the client side version for g_user, you can use g_user.hasRoles() to return true if the user has any roles. Or you can refine is with g_user.hasRole('your_role_name')

Hi Rishi,

Sorry i was reffering to server scripts.

You can use, g_user.hasRoles() in client script.

Thanks,

Maddy