...How can I get the options for a list/record fie...
# suitescript
j
...How can I get the options for a list/record field in a SuiteScript 2.0 user event?
Copy code
function beforeSubmit(context) {
    var rec = context.newRecord;
    var field = rec.getField({ fieldId: 'custbody_select_field' });
    var options = field.getSelectOptions(); // throws
});
TypeError: Cannot find function getSelectOptions in object Field.
Copy code
function beforeSubmit(context) {
    var rec = record.create({ type: record.Type.SALES_ORDER });
    var field = rec.getField({ fieldId: 'custbody_select_field' });
    var options = field.getSelectOptions(); // throws
});
TypeError: Cannot find function getSelectOptions in object Field.
Looks like the
Field
object only has
getSelectOptions
if you load the record in dynamic mode.
Copy code
function beforeSubmit(context) {
    var rec = record.create({ type: record.Type.SALES_ORDER, isDynamic: true });
    var field = rec.getField({ fieldId: 'custbody_select_field' });
    var options = field.getSelectOptions(); // works