Difference between addSelectOption(options) And insertSelectOption(options)

Field.addSelectOption(options)

  • Adds the select options that appears in the dropdown of a field.
  • SuiteScript 2.x Suitelet Script Type and SuiteScript 2.x User Event Script Type (beforeLoad(context))
  • 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.
  • Format:
var selectField = form.addField({
    id : 'custpage_selectfield',
    type : serverWidget.FieldType.SELECT,
    label : 'Select'
});

selectField.addSelectOption({
    value : '',
    text : ''
});

Field.insertSelectOption(options)

Inserts an option into certain types of select and multiselect fields.

  • This method is usable only in select and multiselect 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.
  • Supports Client SCript
  • Format:
var field = call.getField({
    fieldId: 'custpage_select1field'
});


// Insert a new option.

field.insertSelectOption({
    value: 'Option1',
    text: 'alpha'
});

Leave a comment

Your email address will not be published. Required fields are marked *