Setting default value on variable to user manager name

goller
Tera Contributor

Heya!

I'm trying to set the default value of a reference variable on a catalog item. The reference variable is referencing users with a certain role in our organization, leaders/managers have this role.

I've tried gs.getUser().getManagerID() but I get no value? I can confirm that the user has a manager.

Thanks,
goller

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

Hi @goller 

If you are doing this in scoped application it will not work.

Instead you can use below:

 

javascript: var loggedinManager; 
var gr=new GlideRecord("sys_user");
gr.get(gs.getUserID());
loggedinManager=gr.manager.toString();
loggedinManager;

MurthyCh_0-1666271788747.png

 

 

Hope it helps

Thanks,
Murthy

View solution in original post

5 REPLIES 5

Murthy Ch
Giga Sage

Hi @goller 

If you are doing this in scoped application it will not work.

Instead you can use below:

 

javascript: var loggedinManager; 
var gr=new GlideRecord("sys_user");
gr.get(gs.getUserID());
loggedinManager=gr.manager.toString();
loggedinManager;

MurthyCh_0-1666271788747.png

 

 

Hope it helps

Thanks,
Murthy

goller
Tera Contributor

Thank you so much, this worked like a charm!

Aman Kumar S
Kilo Patron

Hi,

You can try below:

gs.getUser().getRecord().getValue('manager')

Best Regards
Aman Kumar

This did not work, probably because I am in a scoped application as Murthy Ch mentioned.