Auto populate manager

Sam198
Mega Guru

Hi all,

I need to autopopulate manager in the manager variable on catalog form for the request for field.

I can add to the default value - javascript:gs.getUser().getManagerID(); and it autopopulates the manager, however if the request for name is changed (for example if an EA is logging on behalf of they would change the request for field name from them to other person) - then the manager field does not update to reflect that changed users manager (stays to the logged in users manager), is there any simple code to update the manager onChange, I am guessing I need catalog client script?

 

thanks.

1 ACCEPTED SOLUTION

dvp
Mega Sage
Mega Sage

If you looking for something on the client side, you can do it using getReference

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

	if (isLoading || newValue == '') {
      return;
   }
	
	var usr = g_form.getReference('requested_for',callBack);
	
}
function callBack(usr){
		g_form.setValue('manager',usr.manager);
}

View solution in original post

7 REPLIES 7

dvp
Mega Sage
Mega Sage

If you looking for something on the client side, you can do it using getReference

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

	if (isLoading || newValue == '') {
      return;
   }
	
	var usr = g_form.getReference('requested_for',callBack);
	
}
function callBack(usr){
		g_form.setValue('manager',usr.manager);
}

Sam198
Mega Guru

Sorry i have not used the GlideRecord scripts so i went with the "Dvps" script and that's working as requirement.

Thanks.

GlideRecord is not a good option in client script.  It will not work when using mobile or Service Portal without some modifications or moving to a script include.  However the code you used will work with Service Portal.