0
votes

In NetSuite, I'm trying to set two of my item sublist fields to mandatory on the opportunity record with a user event script. I used the code suggested via SuiteAnswers to do this, but it's not working. When I log the column.isMandatory, it does not return a value.

My code looks like this:

 function beforeLoad(scriptContext) {
        var rec = scriptContext.newRecord;

        var sublistObj = rec.getSublist({
            sublistId: 'item'
        });

        var columnObj = sublistObj.getColumn({
            fieldId: 'rate'
        });


        columnObj.isMandatory = true;

        log.debug({
            title: 'rate is mandatory',
            details: columnObj.isMandatory
        });

    }
1

1 Answers

1
votes

You can't do that for a built-in field. Netsuite shouldn't generally let you save an item row without a rate but if you find that's an issue you can create a client script that validates line inserts and updates and pops an error if the rate isn't there.