I need to auto populate fields based on Requested for field?

Andre241
Tera Contributor

Hello I need to Auto populate these fields Manager, Email & Business Phone from the User table when anyone selects a user in the the Requested For field of this Catalog Item. find_real_file.png

They need to change every time a different user is selected in the "Who is this request for?" field which fall under the "requested for" type. I know I need a client script probably, but any OOB ideas would be great to. Please I need step by step guidance, scripts or photos. Not links. 

18 REPLIES 18

So for my particular situation. Would my script look like this: 

var user = g_form.getReference('requested_for' , callBack);

Function Callback(user) {

      g_form.setValue('business_phone' , user.business_phone);

      g_form.setValue('manager' , user.manager);

      g_form.setValue('email' , user.email);

var user = g_form.getReference('requested_for' , callBack);

Function Callback(user) {

      g_form.setValue('business_phone' , user.phone);

      g_form.setValue('manager' , user.manager);

      g_form.setValue('email' , user.email);

 

The business phone field on user table is just named phone

Unfortunately, neither one of the scripts are working.

So on the on change one you need to set the variable target to the variable that you are using for the requested for.  See example here called variable name

find_real_file.png

Then the script below works for me in a dev instance

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

var user = g_form.getReference('requested_for' , callBack);

Function Callback(user) {

      g_form.setValue('business_phone' , user.phone);

      g_form.setValue('manager' , user.manager);

      g_form.setValue('email' , user.email);

   }

}

 

 

No I did that. Is there something I'm missing on my variables?

Email Screenshot: 

find_real_file.png

find_real_file.png

Business phones screenshot:

find_real_file.png

find_real_file.png

Manager screenshot:

find_real_file.png

find_real_file.png