我想在netsuite中做一个bin itemfulfillment
。
但我无法得到一个有效的例子。当我运行以下代码时,我收到此错误:
Sublist item field inventorydetail is not a subrecord field
我需要知道创建itemfulfillment
谢谢!
var sales_internalid = '2465'; //saleorderid
var einternalid = '110'; //employeeid
var winternalid = '1'; //washsoueid
var sinternalid = '6'; //itemid
var quantity = 1;
var displayname ='iphone';
var shipgroup = 1;
var salesOrder= nlapiCreateRecord('salesorder', sales_internalid, {recordmode: 'dynamic'});
var obj = nlapiTransformRecord('salesorder', sales_internalid, 'itemfulfillment');
obj.selectLineItem('item',1);
obj.setCurrentLineItemValue('item', 'item', sinternalid );
obj.setCurrentLineItemValue('item', 'location', winternalid );
obj.setCurrentLineItemValue('item', 'quantity', 1);
var subrecord= obj.editCurrentLineItemSubrecord('item', 'inventorydetail');
subrecord.selectLineItem('inventoryassignment', 1);
subrecord.selectNewLineItem('inventoryassignment');
subrecord.setCurrentLineItemValue('inventoryassignment', 'inventorynumber', '1');
subrecord.setCurrentLineItemValue('inventoryassignment', 'quantity', '1');
subrecord.commitLineItem('inventoryassignment');
subrecord.commit();
obj.commitLineItem('item');
var fulfillmentOrderId = nlapiSubmitRecord(itemFulfillment, true);
答案 0 :(得分:1)
通过代码为客户端进行第一次库存转移时,我遇到了同样的问题。当启用“高级存储区管理”功能时,关闭“存储区编号”字段只是一个子记录。如果您正在使用的帐户设置为“使用分档”,则交易行项目上的“分档号”字段将通过其文本值进行设置。示例是在SS 2.0中,但我相信它得到了重点:
newRec = nsRecord.create({
type: nsRecord.Type.INVENTORY_ADJUSTMENT,
isDynamic: true
});
// In dynamic mode must set the subsidiary first.
newRec.setValue({
fieldId: bodyFields.subsidiary,
value: locSub[datain.Location]
});
newRec.setValue({
fieldId: bodyFields.adjustment_Location,
value: datain.Location
});
newRec.setValue({
fieldId: bodyFields.date,
value: date
});
newRec.selectNewLine({
sublistId: columnFields.type
});
newRec.setCurrentSublistValue({
sublistId: columnFields.type,
fieldId: columnFields.item,
value: datain.Item
});
newRec.setCurrentSublistValue({
sublistId: columnFields.type,
fieldId: columnFields.adjust_Qty,
value: datain.Quantity.toString()
});
if (parseFloat(datain.Quantity) > 0) { // If qty is positive must set the Est Unit Cost.
itemVals = nsSearch.lookupFields({
type: nsSearch.Type.ITEM,
id: datain.Item,
columns: fields
});
cost = itemVals.averagecost || itemVals.lastpurchaseprice;
newRec.setCurrentSublistValue({
sublistId: columnFields.type,
fieldId: columnFields.est_Unit_Cost,
value: cost
});
}
//
// Format for binnumbers field is 'ValueText(qty)\rValueText(qty)\rValueText(qty)
// the only exception is in cases of negative qty
//
binText = datain.Bin ? datain.Bin + '(' + datain.Quantity + ')' : '';
newRec.setCurrentSublistValue({
sublistId: columnFields.type,
fieldId: columnFields.bin_Numbers,
value: binText
});
newRec.commitLine({
sublistId: columnFields.type
});
invRecResult.invRecId = newRec.save({
enableSourcing: true,
ignoreMandatoryFields: true
});