我尝试通过自定义记录类型进行库存收据。基本过程是采购订单将创建自定义记录类型,然后自定义记录类型将创建物料收货记录。有我的代码。
function saveRecord(scriptContext) {
var curRec = scriptContext.currentRecord;
var poId = curRec.getValue({
fieldId : 'custrecord_qms_insp_source_doc'
});
var itemId = curRec.getValue({
fieldId : 'custrecord_qms_insp_item'
});
var poRec = record.load({
type : record.Type.PURCHASE_ORDER,
id : poId
});
var itemReceipt = record.transform({
fromType : record.Type.PURCHASE_ORDER,
fromId : poId,
toType : record.Type.ITEM_RECEIPT,
isDynamic : false
});
itemReceipt.setValue({
fieldId : 'exchangerate',
value : 1
});
itemReceipt.setValue({
fieldId : 'customform',
value : 39
});
var today = new Date();
itemReceipt.setValue({
fieldId : 'trandate',
value : today
});
itemReceipt.setSublistValue({
sublistId : 'item',
fieldId : 'location',
line : 0,
value : 4
});
itemReceipt.setSublistValue({
sublistId : 'item',
fieldId : 'quantity',
line : 0,
value : 2
});
var itemSubrecord = itemReceipt.getSublistSubrecord({
sublistId : 'item',
line : 0,
fieldId : 'inventorydetail'
});
itemSubrecord.insertLine({
sublistId : 'inventoryassignment',
line : 0
});
itemSubrecord.insertLine({
sublistId : 'inventoryassignment',
line : 0
});
itemSubrecord.setSublistValue({
sublistId : 'inventoryassignment',
fieldId : 'quantity',
line : 0,
value : 2
});
itemReceipt.save();
}
return {
saveRecord : saveRecord
};
当我运行它时,它一直显示错误消息:"TypeError: field.getSublistName is not a function"
。我不知道为什么显示此消息以及如何解决它。任何帮助将不胜感激。