RE: How to hide sublist fields in beforeload in SuiteScript 2.0 of current record?

The below code gives the following error : ‘

TypeError: Cannot find function updateDisplayType in object standard record.



define(['N/record', 'N/log', 'N/search', 'N/task', 'N/ui/serverWidget'],
function(record, log, search, task, serverWidget) {
function beforeLoad(scriptContext) {
log.audit('In before laod UE');
if (scriptContext.type == 'create' || scriptContext.type == 'copy') {
var currentRecord = scriptContext.newRecord;
var deliItem = currentRecord.setSublistValue({

sublistId: 'recmachcustrecord_rent_rod_delivery_note',

fieldId: 'custrecord_rent_rod_delivered_item',

line: 0,

value: 400


displayType: serverWidget.FieldDisplayType.HIDDEN

return {

beforeLoad: beforeLoad





ankkhan7 Rookie Asked on March 12, 2020 in SuiteScript.
Add Comment
2 Answers
Best answer

You are confusing the record and form objects. Record.setSublistValue returns a record.Record, which does not have a updateDisplayType method.

Use scriptContext.form to access the serverWidget.Form, then get the serverWidget.Sublist, then get the serverWidget.Field. Then you can use updateDisplayType on the Field.

Advanced Answered on March 12, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.