https://netsuiteprofessionals.com logo
#suitescript
Title
# suitescript
p

pen one

04/28/2022, 8:51 PM
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

jen

04/28/2022, 8:53 PM
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

pen one

04/28/2022, 8:55 PM
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

jen

04/28/2022, 8:57 PM
where is the error being thrown, when you remove or when you add an option?
p

pen one

04/28/2022, 8:59 PM
j

jen

04/28/2022, 9:03 PM
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

pen one

04/28/2022, 9:04 PM
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

jen

04/28/2022, 9:07 PM
Is this in UserEvent? Suitelet?
p

pen one

04/28/2022, 9:08 PM
UserEvent
i removed the
removeSelectOption
and still got the error but this time at
Field.insertSelectOption
.
b

battk

04/28/2022, 9:52 PM
read the important warnings from Form.addField
p

pen one

04/28/2022, 9:55 PM
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

battk

04/28/2022, 10:07 PM
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

pen one

04/28/2022, 10:41 PM
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

battk

04/28/2022, 10:42 PM
emphasis on your own custom entity field
p

pen one

04/28/2022, 10:42 PM
got it.
106 Views