我正在尝试使用一个MapReduce脚本,该脚本将获取我的项目输入并打开项目记录,选择基本价格,将所有值设置为空或空白,然后在另一个定义的价格级别上重复。我被困在第一级,基本价格。它正在抛出以下代码: user_error","消息:"请输入下面的缺失价格是我的代码。我缺少什么或不称呼正确?
function(email, error, record, runtime, search, log) {
function nullPricing(itemId, itemType){
try{
log.audit({title:"nullPricing"});
var itemRecord = record.load({
"type": record.Type.INVENTORY_ITEM,
"id": itemId,
"isDynamic": true
});
var priceId;
var currencyId = 1;
priceId = 'price1';
log.debug("Currency:", priceId);
//var priceId = price1;
var basePrice = 1000;
//log.debug("Base Price:", basePrice);
//log.debug("Details:","itemId = " + itemId);
columnCount = itemRecord.getMatrixHeaderCount(priceId, 'price');
//log.debug("Matrix Count:", columnCount);
for (var cnt=1; cnt<=columnCount; cnt++)
{
itemRecord.selectLine(priceId, 1);
itemRecord.setCurrentMatrixSublistValue(priceId, 'price', cnt, basePrice);
itemRecord.commitLine(priceId);
}
itemRecord.save();
}catch(exception){
log.debug("nullPricing Error Message:",exception);
}
}
function getInputData() {
try{
log.debug("Get Input", "Initiated");
//Item Search
var itemSearch = search.load({
id: 'customsearch_bwd_null_pricing'
});
log.debug("itemSearch", itemSearch);
log.debug("GetInputData", "Completed");
return itemSearch;
}catch(exception){
log.debug("GetInputDate Error Message:",exception);
}
}
function map(context) {
try{
var searchResult = JSON.parse(context.value);
log.debug("searchResult", searchResult);
var itemId = searchResult.id;
log.debug("itemId", itemId);
var itemType = searchResult.recordType;
log.debug("itemType", itemType);
//Call the function
nullPricing(itemId, itemType);
}catch(exception){
log.debug("Map Error Message:",exception);
}
}
事先感谢您的帮助!
brad
价格级矩阵的问题是矩阵0:0位置为基本价格:QTY0如果您尝试将值输入QTY1 NetSuite需要您输入该价格水平的数量。
此代码对我有动态记录:
myRecord.selectLine({
sublistId: 'price',
line: 0
});
myRecord.setCurrentMatrixSublistValue({
sublistId: 'price',
fieldId: 'price',
column: 0,
value: basePrice,
ignoreFieldChange: true,
fireSlavingSync: true
});
myRecord.commitLine({
sublistId: 'price'
});
祝你好运。