You must have at least one valid line item for this transaction error will stop us from creating an item fulfillment from a sales order at the stage of record.transform()
if we did not specify an inventoryLocation in the defaultValue parameter.
Here is a working suitelet code which creates an item fulfillment via record.transform(). You may replace ids with yours and remove the inventorydetail part if you don’t need it
如果我们在初始化阶段不填写库存位置信息,”您必须让此事务处理拥有至少一个有效的行项目“这个错误会直接在record.transform()阶段直接弹出,阻止我们从销售订单创建货品履行。
附上一个suitelet的代码,用于通过record.transform()创建货品履行。你可能需要替换id,如果不需要库存编号那段代码请自行移除。
/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
define(['N/record'],
(record) => {
const onRequest = (scriptContext) => {
let ifRecObj = record.transform({
fromType: 'salesorder',
fromId: 111111, //your sales order id
toType: 'itemfulfillment',
isDynamic: true,
defaultValues:{
inventorylocation: 2222 //your location id
}
});
for (let i = 0; i < 1; i++) {
ifRecObj.selectLine({ sublistId: 'item', line: i });
ifRecObj.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: 1 });
//inventory detail start
let invDetailRecObj = ifRecObj.getCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail'
});
invDetailRecObj.selectLine({
sublistId: 'inventoryassignment',
line: 0
});
invDetailRecObj.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'issueinventorynumber',
value: 3333 //your inventory detail id
});
invDetailRecObj.setCurrentSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
value: 1
});
invDetailRecObj.commitLine({
sublistId: 'inventoryassignment',
});
//inventory detail end
ifRecObj.commitLine({ sublistId: 'item' });
}
const ifRecordId = ifRecObj.save({ enableSourcing: true, ignoreMandatoryFields: false });
}
return { onRequest }
});
Comments
I got the same respond when Initialize from a sales order to fulfillment with PHP Toolkit 2021_1. The same code was working last year before we enabled the “MULTI-LOCATION INVENTORY” a few months ago. Do you know if your method can fix this issue with php SOAP too?
Hi Kevin, Not sure whether you can add additional default value via that Toolkit – just a simple tweak if you can add `inventorylocation` to the defaultValues
Thanks for your reply. Sorry for not reply for months, my 2 months old baby girl made me almost no sleep….. Do you mean we can add something to the toolkit file like NetSuiteService.php? If so, would you please explain how to do it?
Thank you, our company recently switched to cross-subsidiary fulfillments and we were getting this error. The `defaultValues` parameter seems to have solved the issue.
Hi there, Thanks for sharing your info. Enjoy your day. Regards, John
would you please explain more how does “The `defaultValues` parameter seems to have solved the issue.” works? Netsuite told me that the SOAP does not pass the inventoryLocation field. is it possible to set that field to defaultValues with SOAP? Thank you.