【问题标题】:Suitescript 2.0 - How to show a field and update value based on dropdown?Suitescript 2.0 - 如何显示字段并根据下拉列表更新值?
【发布时间】:2019-10-25 14:34:12
【问题描述】:

I have a drop down that, when a particular option is selected a hidden field will be displayed and that field which have a new value.我能够显示该字段,但无法使用该值填充该字段。脚本如下:

           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】:

    note.setValue = "";

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

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

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

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

    context.currentRecord.setValue({
      fieldId: 'custbody_note',
      value: "test",
    });
    

    【讨论】:

      猜你喜欢
      • 2021-02-26
      • 2020-02-14
      • 1970-01-01
      • 1970-01-01
      • 2016-09-20
      • 1970-01-01
      • 2019-04-17
      • 1970-01-01
      • 2018-04-16
      相关资源
      最近更新 更多