Hi all, Any idea why the below code runs in conso...
# suitescript
p
Hi all, Any idea why the below code runs in console and not on PageInit?
Copy code
require(['N/currentRecord'], currentRecord => {

        const validOpts = [
            'A',
            'B',
            'C'
        ]

        const rec = currentRecord.get()
        const classField = rec.getField({ fieldId: 'class' })
        const allOpts = classField.getSelectOptions()
        const invalidOpts = allOpts.filter(a => !validOpts.includes(a.text))

        // Filter invalid Options
        invalidOpts.forEach(o => {
            classField.removeSelectOption({ value: o.value })
        })
    })
Error on PageInit:
"That operation is not supported for this type of UI object: null. It is only supported for type: null."
b
neither should work
you cant remove select options from native fields
suggesting that at some point invalidOpts has no elements to remove and isnt actually trying to perform an invalid operation