We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

make variable dependent on another variable

DreDay3000
Tera Guru

I have variables on a record producer that need to be dependent on the previous variable. I have tried using the auto-populate but it doesn't seem to work. Is there another way to achieve this?

1 ACCEPTED SOLUTION

DreDay3000
Tera Guru

javascript:'building='+current.variables.building

View solution in original post

3 REPLIES 3

brianlan25
Kilo Patron

What do you mean by dependent? That to say you want to make a variable let say mandatory based on the previous. However, you are talking about auto-populate so are you trying to populate what is in the variable based on the previous one?

Deepak Shaerma
Mega Sage

Hi @DreDay3000 

Create a catalog client script. 

 

//onchange client script 

if (newValue == ‘option_1_value’) {
    // Set the options for Variable B when Option 1 is selected in Variable A
    g_form.clearOptions(‘variable_b’);
    g_form.addOption(‘variable_b’, ‘1’, ‘Option B1’);
    g_form.addOption(‘variable_b’, ‘2’, ‘Option B2’);
  } else if (newValue == ‘option_2_value’) {
    // Set different options for Variable B when Option 2 is selected in Variable A
    g_form.clearOptions(‘variable_b’);
    g_form.addOption(‘variable_b’, ‘3’, ‘Option B3’);
    g_form.addOption(‘variable_b’, ‘4’, ‘Option B4’);
  }
  // Continue for other options as necessary
}

Note: use g_form.setValue('field_name' , 'value'); to set the variable 2 value based on variable 1 

Please mark it helpful and accepted if this helps you in somehow. This will help both community and me.

 

Thanks and Regards 

 

Deepak Sharma 

 

DreDay3000
Tera Guru

javascript:'building='+current.variables.building