Suitescript 2.0-如何显示字段并基于下拉菜单更新值?

问题描述 投票:0回答:1

我有一个下拉列表,当选择一个特定选项时,将显示一个隐藏字段,并且该字段具有新值。我能够显示该字段,但无法用该值填充该字段。下面的脚本:

           function fieldChanged(context) {
                var records = context.currentRecord;
                if (context.fieldId == 'custbody_data') {
                    var note = context.currentRecord.getField({ fieldId: 'custbody_note' });

                    var type = records.getValue({
                        fieldId: 'custbody_data'
                    });

                    if (type == "2") {
                        note.isDisplay = true;
                        note.setValue = "test";

                    } else if (type == "1") {
                       note.isDisplay = false;
                       note.setValue = "";
                    }
                }
            }

return {
fieldChanged: fieldChanged
}
netsuite suitescript2.0
1个回答
0
投票

note.setValue = "";

您尝试做的事情有两个问题:

  1. 使用NetSuite API,要操作记录中的字段值,您需要使用N/currentRecord#Record对象,而不是N/currentRecord#Field。换句话说,您需要呼叫context.currentRecord.setValue()

  2. setValuemethod, not a property。即您需要使用新值调用函数setValue(),而不要像尝试那样为它分配一个值(note.setValue = "new value")。

将它们放在一起,更新字段值的正确语法是:

context.currentRecord.setValue({
  fieldId: 'custbody_note',
  value: "test",
});
© www.soinside.com 2019 - 2024. All rights reserved.