I am using getSelectOptions over the array of valu...
# general
n
I am using getSelectOptions over the array of values. It is only working for the 1st option and then returns empty array for the next options. I have tried with hardcoded values and experienced the same behavior. Any thoughts?
n
getSelectOptions used on a field object returns an array of objects, what do you mean it works for the 1st but then an "empty array" are you talking about 2 different select lists? And hard coded values? What are you trying to do?
n
Yes, I get the text like ["English", "French"] as options. I pass each of the element to getSelectOptions with operator of "is". It works for English, but not for French. If I change the array to ["French", "English"], it works for French, but not for English.
b
what does your code look like
n
Copy code
attr.value.forEach(val => {
   var opt = fld.getSelectOptions({filter: val, operator: 'is'});
   if (!!opt && opt.length > 0) {
      options.push(opt[0].value);
   }
   else {
      var opt = fld.getSelectOptions({filter: val, operator: 'contains'});
      if (!!opt && opt.length > 0) {
         options.push(opt[0].value);
      }
   }
});
b
code looks weird, but reasonable
nothing to my knowledge says that getting select options affect the available select options
Copy code
["English", "French"].forEach(val => {
   var opt = fld.getSelectOptions({filter: val, operator: 'is'});
   if (!!opt && opt.length > 0) {
      options.push(opt[0].value);
   }
   else {
      var opt = fld.getSelectOptions({filter: val, operator: 'contains'});
      if (!!opt && opt.length > 0) {
         options.push(opt[0].value);
      }
   }
});
and
Copy code
["French", "English"].forEach(val => {
   var opt = fld.getSelectOptions({filter: val, operator: 'is'});
   if (!!opt && opt.length > 0) {
      options.push(opt[0].value);
   }
   else {
      var opt = fld.getSelectOptions({filter: val, operator: 'contains'});
      if (!!opt && opt.length > 0) {
         options.push(opt[0].value);
      }
   }
});
should have the same values added to the options array
though they may end up in a different order
n
yes, that's my assumption as well but it was not working.