I have a script that is supposed to filter out a s...
# suitescript
p
I have a script that is supposed to filter out a select field I created using
serverWidget.FieldType.Select
. The filter is supposed to take place when a custbody field is changed but the filter is not working and in console I see the following error:
The following operation or use case is not yet supported in SuiteScript: update popup select options
. Below is the part of the script that is being used to filter the field:
Copy code
var addLabellCtc = record.getField('custpage_contact_address_label');
        addLabellCtc.removeSelectOption({value : null});
        if(addressSearchResults.length != 0) {
          for(var i in addressSearchResults) {
            addLabellCtc.insertSelectOption({
                value : addressSearchResults[i].id,
                text : addressSearchResults[i].getValue({
                    name: "addresslabel",
                    join: "Address"
                })
            });
          }
        }
What am I doing wrong?
j
Are there a large number of options --- if so, it will make a popup search instead of a normal drop down, and the error you are getting implies that removing/adding options from that is not supported.
whether it renders as a popup is determined by whether or not the number of options exceeds the value you have for
MAXIMUM ENTRIES IN DROPDOWNS
in your Preferences
p
the search I am running is only bringing back 1-5 results (at most). Or is it based on how many total address labels there are - which is a large amount?
j
where is the error being thrown, when you remove or when you add an option?
p
j
How was the select field added exactly? Note that the removeSelectOption() fn states: This method is usable only in select fields that were added by a front-end Suitelet or beforeLoad user event script. The IDs for these fields always have a prefix of custpage.
p
Copy code
form.addField({
                id: 'custpage_contact_address_label',
                type: serverWidget.FieldType.SELECT,
                label: 'Select Address',
                source: '-137'
            });
i am getting all of the address labels in the drop down but goal is to filter it by a contact the user selects in a custbody field.
j
Is this in UserEvent? Suitelet?
p
UserEvent
i removed the
removeSelectOption
and still got the error but this time at
Field.insertSelectOption
.
b
read the important warnings from Form.addField
p
Thanks. Assume you mean this: After you create a select or multi-select field that is sourced from a record or list, you cannot add additional values with Field.addSelectOption(options). The select values are determined by the source record or list.
But my goal is to filter - not add. I thought I could filter using the removeSelectOption and insertSelectOption but I guess I cannot,
b
the usual for addressbook is to have a native addressbook field that has a filter on a custom entity field that you created and can control
p
my goal was to filter by the contact name and show only addresses associated with a contact but when I try doing this in the UI I get an error stating that the contact field does not match the filter Entity - hence why I am trying it this way.
b
emphasis on your own custom entity field
p
got it.
223 Views