Suitescript-基于下拉值的隐藏字段

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

如果在下拉字段中选择了某个选项,我需要在记录中隐藏字段。无论我在下拉菜单中选择哪种方式,使用以下代码都是隐藏的。任何帮助表示赞赏:

define([], function () {
  /*Field Change event*/
               function fieldChanged(context) {
                    var records = context.currentRecord;
                    if (context.fieldId == 'custbody_pick_ship') {
                        var customElement = context.currentRecord.getField({ fieldId: 'custbody_zone' });
                        var type = records.getValue({
                            fieldId: 'custbody_pick_ship'
                        });

                        if (type = "Pick Up") {
                           customElement.isDisplay = false;
                        } else {
                            customElement.isDisplay = true;
                        }
                    }
                }

return {
fieldChanged: fieldChanged
}
}
);
netsuite suitescript
1个回答
0
投票

您的问题在if (type = "Pick Up")行中。 JavaScript中的单个=是一个赋值运算符,这意味着您将type变量的值setting设置为"Pick Up"。由于"Pick Up"是一个非伪造的值,因此表达式将始终评估为true。您需要使用=====来测试相等性(通常为the triple equal is preferable)。

if (type === "Pick Up") {
   customElement.isDisplay = false;
} else {
   customElement.isDisplay = true;
}
© www.soinside.com 2019 - 2024. All rights reserved.