我将 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};
您可能必须保存记录。
致电:
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};