Difference between gs.hasRole(‘abc ’)and gs.getUser().hasRole(‘abc’) if I want to use in acl script

Vasavi4
Tera Contributor

Difference between gs.hasRole(‘abc ’)and gs.getUser().hasRole(‘abc’) if I want to use in acl script. Which one is better. I saw same functionality when using both ways. Please suggest. 

8 REPLIES 8

Rajat_Choudhary
Tera Expert

Hi Vasavib1,

Please refer the link below. https://servicenowguru.com/scripting/user-object-cheat-sheet/

Hope this will be helpful.

Please mark answer as correct if it clarifies the doubt 

Thank you

You are welcome vasavib1.

You can mark that answer helpful.Happy coding .

Jake Sadler
Kilo Sage

Hi,

 

The gs.hasRole is a GlideSystem(gs) method.

The gs.getUser(),hasRole method is a glideUser method.

 

They both achieve the same thing.

 

Most people will set a var like

var user = gs.getUser();

 

and then pull multiple details from the user like;

 

user.getID();

user.getLastName();

 

If this solved you issue please ark my answer as correct or as helpful