我正在尝试使用工作流脚本访问NetSuite中的子列表。我在所有销售订单上放置了一个按钮,按下后将执行此脚本。我不断收到我的子列表为空的错误。如果它为null可以解释为什么?
function(record) {
var salesorder = record.newRecord;
var salesordernumber = salesorder.getValue('tranid');
var date = salesorder.getValue('trandate');
var sublist = salesorder.getSublistValue({
Sublistid : 'item'
});
log.debug('Employee Code', salesordernumber);
log.debug('Supervisior Name', date);
log.debug('itemr', sublist);
/**
* Definition of the Suitelet script trigger point.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.newRecord - New record
* @param {Record} scriptContext.oldRecord - Old record
* @Since 2016.1
*/
});
function onAction(context) {
return {
onAction : onAction
};
}
答案 0 :(得分:2)
//Load created Sales Order so that we can fetch data
var salesObjRecord = record.load({
type: record.Type.SALES_ORDER,
id: salesOrderID,
isDynamic: true
});
var itemDetailsObj = new Object();
var numLines = salesObjRecord.getLineCount({
sublistId : 'item'
}); // to get sublist line number
if (numLines > 0) {
for (var i = 0; i < numLines; i++) {
itemDetailsObj.amount = salesObjRecord.getSublistValue({
sublistId : 'item',
fieldId : 'amount',
line : i
});
itemDetailsObj.rate = salesObjRecord.getSublistValue({
sublistId : 'item',
fieldId : 'rate',
line : i
});
itemDetailsObj.quantity = salesObjRecord.getSublistValue({
sublistId : 'item',
fieldId : 'quantity',
line : i
});
}
}
答案 1 :(得分:0)
record.getSublistValue()返回子列表字段的值。子列表字段由3个参数唯一标识:
所有这些参数都是必需的,但您的代码并未提供所有这些参数。