无法在套件脚本2.0中找到函数setValue ?



我写了这个预定的脚本来从保存的搜索中取消drop-off订单,但是它给了我这个错误:

{在object object object中找不到setValue函数}

我从保存的搜索中得到了值,但试图更新字段不工作代码是

/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
*/
define(['N/search','N/record', 'N/log'], function(search, record,log) {
function execute() {
var mySalesOrderSearch = search.load({
id: 'customsearch1199'
});
var resultSet = mySalesOrderSearch.run();
var results = resultSet.getRange({ start: 0, end: 1000 });
for (var i = 0; i < results.length; i++) {
printResults(results[i]);
}
function printResults() {
log.debug({ title: "sales order id", details: results[i].id });
record.setValue({
fieldId: 'custbody_sor_dropoffstatus',
value: 'NOT_STARTED'
}).setValue({
fieldId: 'custbody_sor_dropoffqr',
value: ''
}).setValue({
fieldId: 'custbody_sor_dropoffimageurl',
value: ''
}).setValue({
fieldId: 'custbody_sor_dropoffstarttime',
value: ''
}).setValue({
fieldId: 'custbody_sor_dropoffarrivetime',
value: ''
}).setValue({
fieldId: 'custbody_sor_dropoffcompletetime',
value: ''
});
record.save({
enableSourcing: true,
ignoreMandatoryFields: false
});
log.debug({
title: 'Debug',
details: 'Done' + sorId
});
}
return true;
}
return {
execute: execute
};
})

只能从记录中调用setValue。记录对象。你可以通过load来获取一个对象:

var objRecord = record.load({
type: record.Type.SALES_ORDER,
id: results[i].id
});

但是,我建议检查记录。如果你只是更新主体字段,请先提交字段。

最新更新