Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Display User Department in Catalog item Variable

ch_karthikeya
Tera Contributor
1 ACCEPTED SOLUTION

Hi Ashutosh,



i requested currently logged in   user Department only



now i got the result :   javascript: gs.getUser().getDepartmentID();




find_real_file.png


View solution in original post

12 REPLIES 12

Harneet Sital
Mega Sage
Mega Sage

Hi Karthikeya,



You can try to use "g_form" API to fetch values of currently logged in user to update the department field with,


find_real_file.pnghttps://www.servicenowguru.com/scripting/user-object-cheat-sheet/


https://www.servicenowguru.com/scripting/user-object-cheat-sheet/



If it should be dependent on a caller field then use Script Include to populate fields from the User table. Please check out this link,



Re: Auto populate user information on Load


perlemmingwittu
Kilo Expert

Hi



For the logged on user you can set the default value to either:


javascript:gs.getUser().getRecord().getValue('department');


if it is a string value



or



javascript:gs.getUser().getRecord().getDisplayValue('location');


if it is a value from a reference field.



Best regards


Per


Hi,



i have tried with your two logical scripts but not working



find_real_file.png


Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,



Which users department you want logged in user or Requested for user.



Thanks,