Remove option from Reference field when...

MWright1
Giga Guru

I have a form with 3 reference fields.  The idea is to not have the user select the same option in any of the 3 fields:find_real_file.png

So if the user selects "Financial Services" for Primary, they should not be allowed to select the same for Secondary or Tertiary.  Therefore I would like to remove those options from these reference fields.

I created a Catalog Client Script onchange of the Primary Specialty field

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

   g_form.removeOption('secondary_specialty_en',newValue);
   g_form.removeOption('tertiary_specialty_en',newValue);  
   
}

 

It does nothing... the option still exists...  Not sure what I am doing wrong.  Please help.

1 ACCEPTED SOLUTION

OlaN
Giga Sage
Giga Sage

Hi,

Removing options will not work on a reference field. It's only valid if it were a choice field.

In this case you would need to create an advanced reference qualifier, and a script include on all three fields, and use the input value to determine which results should be displayed.

View solution in original post

8 REPLIES 8

dmathur09
Kilo Sage
Kilo Sage

Hi,

Are the values in Secondary and Tertiary coming from any reference field or from choice field.

Regards,
Deepankar Mathur

All three fields are Reference fields pointing to the same source.

Thanks.

Hi MWrite,

If they are referencing to some table, you would need to create a advanced reference qualifier. Since g_form.removeOption will not work, as it only works if you have choices.

Regards,
Deepankar Mathur

OlaN
Giga Sage
Giga Sage

Hi,

Removing options will not work on a reference field. It's only valid if it were a choice field.

In this case you would need to create an advanced reference qualifier, and a script include on all three fields, and use the input value to determine which results should be displayed.