hasRole in Server and Client

Sachin G K1
Kilo Sage

Hi, 

 

We know that g_user.hasRole('itil'); will return true if user has itil role or admin role. Similarly does, gs.hasRole('itil'); works the same or does it return true only when user has itil role.

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi @Sachin G K1 both method works the same, the difference is

g_user.hasRole() // client side call

gs.hasRole() // server side call

 

you could also use gs.hasRoleExactly()// it will check for admins as well

Regards
Harish

View solution in original post

9 REPLIES 9

Harish KM
Kilo Patron
Kilo Patron

Hi @Sachin G K1 both method works the same, the difference is

g_user.hasRole() // client side call

gs.hasRole() // server side call

 

you could also use gs.hasRoleExactly()// it will check for admins as well

Regards
Harish

Hi Harish,

Just to clarify, gs.hasRole('itil'), will this return true if user doesn't have itil role but has admin role. Am i correct?

You are correct. The statement gs.hasRole('itil'); will not return true even if the user has the admin role.

please mark helpful and accept solution if you get answer

Hi @Sachin G K1 yes, it will return true for admin

Regards
Harish