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

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

@keval 

if user changes Requested For then you will have to write onChange client script on Requested for and get the other variable details and populate it.

you can use getReference() with callback method to do this

Example below:

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading) {
		return;
	}

	if(newValue == ''){
		g_form.clearValue('location');	// location variable name here
	}

	var ref = g_form.getReference('requested_for', callBackMethod);	// requestedFor variable name
}

function callBackMethod(ref){
	if(ref.location)
		g_form.setValue('location', ref.location); // location variable name here
}

Regards
Ankur

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

Hi Ankur,

The Department field is displayed properly by your help

but Location and Employee Id are still not display

Location variable is referring to cmn_location table and  Employee ID is string variable

Thanks & Regards

Keval

 

then it should work fine.

did you check you are using correct field name for employee_number and user has that employee number populated.

also location is empty or not for that user in user table?

Regards
Ankur

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