Get Cost Center Field to automatically populate

DeIvory Gordon
Tera Guru

Hello,

 

On a catalog item, how do I get the cost center field to automatically populate when the Requested For field populates and/or when Location field is populated.

1 ACCEPTED SOLUTION

Danish Bhairag2
Tera Sage
Tera Sage

Hi @DeIvory Gordon ,

 

You can try the autopopulate feature in the catalog item where u just need to specify based upon which field selection on the form it is suppose to autopopulate for eg in ur case Requested For, then select the table as user as the value will be fetching from der & the dotwalk field as cost centre.

Here without script u will be able to achieve ur request,

 

Thanks,

Danish

View solution in original post

4 REPLIES 4

Danish Bhairag2
Tera Sage
Tera Sage

Hi @DeIvory Gordon ,

 

You can try the autopopulate feature in the catalog item where u just need to specify based upon which field selection on the form it is suppose to autopopulate for eg in ur case Requested For, then select the table as user as the value will be fetching from der & the dotwalk field as cost centre.

Here without script u will be able to achieve ur request,

 

Thanks,

Danish

Thank you so much it worked, and you made the steps simple to follow!!!!!

@DeIvory Gordon  Happy to Help 🙂

Sumanth16
Kilo Patron

Hi @DeIvory Gordon ,

javascript: var costCenter = ''; var gr = new GlideRecord('sys_user'); gr.get(gs.getUserID()); costCenter = gr.getValue('cost_center'); costCenter;

 

Please verify the name of the company field you're using on the cost center table and also please note the correct method used for the GlideSystem API to get the company ID of the user.

 

Another method:

Then use onChange client script on Requested For

function onChange(control, oldValue, newValue, isLoading) {

	if(isLoading)
		return;

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

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

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

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda