how to set default values in catalog item

keval3
Tera Contributor

Hello All,

I have one requirement in which I have to set default value Requested for,Location,Employee Id,and Department.

I set the default value of Requested for but not able to set remaining. I attached the screen short of both

find_real_file.png

 

 

find_real_file.png

Please let me know if any one have idea.

Thanks & Regards

Keval

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I assume Location variable is referring to cmn_location table; so do this

javascript: gs.getUser().getLocation();

I assume Department variable is referring to cmn_department table; so do this

javascript: gs.getUser().getDepartmentID();

I assume Employee ID is string variable; so do this

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

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Hi Ankur,

I am asking about default value once the catalog item will open then need default value 

Requested for and department are displayed properly by using your help but location and Employee id are not display by default side. 

find_real_file.png

Hi,

Did you check that user i.e. System Administrator has employee ID and location populated in user record?

are your using this in global scope or scoped app?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  i am trying to autopopulate employee number in order guide.Its not working

quintenvandenb1
Giga Expert

Hello Keval

 

From what I can see, this can be solved with an onChange client script.

Create a new onChange client script that runs onChange on the requested_for field. Then create a client script with a getReference() to retrieve the fields of the requested_for variable.


g_form.getReference('requested_for', function(userData){

g_form.setValue('department', userData.department);

});

https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideFormAPI#r_GlideForm-GetReference_S_F?navFilter=getReference

 

Kind regards

 

Quinten

Rupali1
Tera Contributor

Hii Keval,

  use javascript:gs.getUser().manager.name;

 

 

 

 

 

 

 

Marks as helpful or correct if it helps you.

Thanks,

Rupali Bondar