Auto Populate a field value based on another field value

ID NOBLE
Tera Expert

Hello,

 

Please I need help on how to auto populate a field value based on the value selected on reference field on a form.

 

For example, we have a variable set included in this catalog item and we want to auto-populate the value of one of the variables in that variable set based on the value selected on a reference field in the form.

 

Thanks.

2 REPLIES 2

Alp Utku
Mega Sage

You could write onChange Catalog Client Script. Example code is below

 

var MyVal = g_form.getValue('name_of_the_reference_field').getDisplayValue();

If (MyVal == "xyz") {

g_form.setValue('field_name_to_be_set', 'display_value', 'backend_value') ;

}

Hi @Alp Utku,

 

What will I use instead of the xyz you used in the script please? This is because we won't know the value that users will select in the field until they make their choice for the field and am sure the value will vary by users

 

Thank you.