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

Can you give an example of what this would look like or provide a link to a similar one?

Hi,

Example below.

Also note, this solution doesn't prohibit you to select the same users if you select the second variable before the first one, in that case, you will need to make some adjustments.

But I'm sure you get the general idea.

Script include (just change the query to whatever your requirement looks like:

find_real_file.png

 

Reference qualifier on variable on catalog item (first_user and then second_user variable):

find_real_file.png

find_real_file.png

MWright1
Giga Guru

Thank you.  

Hi Wright,

Did the above solution worked for you. I do have the same requirement now.

Regards,

Navyaa