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 set default value in catalog item form

U K
Kilo Explorer

Hi All,

In service catalog , catalog item form i created a variable set .It contains two fields named 

1.user name--reference field --sys_user table

2.manager-reference field --sys_user table

i want to set default values for these fields as current login user.

i am able to get user name ,,i want to know how to get manager name and set as default value.

 

Thanks

U K

find_real_file.png

 

6 REPLIES 6

Mike Patel
Tera Sage

create onLoad client script for that cat item. bolded is your variables names

 

function onLoad() {
var user = g_form.getReference('req_for', populateReqForDetails);

function populateReqForDetails(user) {
g_form.setValue('req_for_manager', user.manager);
}
}

scott barnard1
Kilo Sage

Hi UK

 

Just go to the variable in the item and find the default value field

paste in

And if you want manager

 

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

Hi 

Thaks for response,

It works for user name , but i want to get manager name.