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





Rookie Asked on March 12, 2020 in SuiteScript.
Add Comment
2 Answer(s)
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

Do you have any code snippet for the same in UserEvent script in 2.0?

Rookie Answered on March 12, 2020.

Documentation for getting the field is fairly clear about how the code should look. Same thing about using updateDisplayType

on March 12, 2020.

Thanks buddy got it.

on March 12, 2020.

Did something like this :


var itemField = form.getSublist({

id: 'recmachcustrecord_rent_rod_delivery_note'


id: 'custrecord_rent_rod_delivered_item'


displayType: serverWidget.FieldDisplayType.HIDDEN


on March 12, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor