如何使用 SuiteScript 在 NetSuite 中设置另一条记录中的字段值

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

我将 SuiteScript 代码部署到 netsuite 并应用于发票,该发票在创建后将在创建它的销售订单中设置字段值。但代码对销售订单记录没有任何影响,也没有弹出任何错误。

function afterSubmit(context) {
        var curRec = context.newRecord;
        //internal id of the invoice
        var ciId = curRec.id;
        //internal id of the sales order I want to set value in
        var piId = curRec.getValue(
            {
                fieldId: 'createdfrom'
            }
        );

        var loadPI = record.load(
            {
                type: record.Type.SALES_ORDER, 
                id: piId,
                isDynamic: true,
            }
          );
          // the field in the sales order that I want to change
          loadPI.setValue(
            {
                fieldId: 'custbody55',
                value: true
            }
          );
}
return{afterSubmit: afterSubmit};
netsuite suitescript suitescript2.0
1个回答
0
投票

您可能必须保存记录。

致电:

loadPI.save();
,即(您的代码已更新):

function afterSubmit(context) {
  var curRec = context.newRecord;
  //internal id of the invoice
  var ciId = curRec.id;
  //internal id of the sales order I want to set value in
  var piId = curRec.getValue(
    {
      fieldId: 'createdfrom'
    }
  );

  var loadPI = record.load(
    {
      type: record.Type.SALES_ORDER,
      id: piId,
      isDynamic: true,
    }
  );
  // the field in the sales order that I want to change
  loadPI.setValue(
    {
      fieldId: 'custbody55',
      value: true
    }
  );
  loadPI.save();
}
return{afterSubmit: afterSubmit};
© www.soinside.com 2019 - 2024. All rights reserved.