Boris Yasen
11/06/2023, 8:12 PMrecord.transform()
however, Components sublist is a challenge for me.
var woIssueRec = record.transform({fromType:record.Type.WORK_ORDER, fromId: woID, toType:record.Type.WORK_ORDER_ISSUE, isDynamic:false});
for(let i=0; i<3;i++){
woIssueRec.insertLine({sublistId:"component", line:i, ignoreRecalc:false});
And here comes the most challenge part.
let compInventoryDetailRec = woIssueRec.getSublistSubrecord({
sublistId: 'component',
fieldId: 'componentinventorydetail',
line: i
});
log.debug('component loop', 'insertLine2');
compInventoryDetailRec.insertLine({
sublistId: 'inventoryassignment ',
line: 0
});
compInventoryDetailRec.setSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'binnumber',
line: 0,
value: 'binNumber'
});
log.debug('component loop', 'insertLine4');
compInventoryDetailRec.setSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'issueinventorynumber',
line: 0,
value: 'lotNumber'
});
But this shows me the error says You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.
Could I know what's wrong please?
Component is a sublist, Inventory Detail is subrecord of sublist and InventoryAssignment is sublist of Inventory Detail. Am I right?ericbirdsall
11/07/2023, 3:05 PMBoris Yasen
11/07/2023, 3:06 PMericbirdsall
11/07/2023, 3:07 PMBoris Yasen
11/07/2023, 3:08 PMericbirdsall
11/07/2023, 3:09 PMcomponent
list already populated?Boris Yasen
11/07/2023, 3:10 PMericbirdsall
11/07/2023, 3:11 PMwoIssueRec.insertLine({sublistId:"component", line:i, ignoreRecalc:false});
Unless you're trying to add an additional component that isn't on the original Work Order at allBoris Yasen
11/07/2023, 3:12 PMericbirdsall
11/07/2023, 3:12 PMBoris Yasen
11/07/2023, 3:13 PMericbirdsall
11/07/2023, 3:14 PMericbirdsall
11/07/2023, 3:15 PMBoris Yasen
11/07/2023, 3:15 PMBoris Yasen
11/07/2023, 3:16 PMericbirdsall
11/07/2023, 3:19 PMericbirdsall
11/07/2023, 3:20 PMvar fulfillmentLineCount = fulfillment.getLineCount({
sublistId: 'item'
});
for (var i = 0; i < fulfillmentLineCount; i++) {
if (parseFloat(allInfo.table[i].quantityCompleted) > 0) {
fulfillment.setSublistValue({
sublistId: 'item',
line: i,
fieldId: 'quantity',
value: parseFloat(allInfo.table[i].quantityCompleted)
});
}
if (allInfo.table[i].pickedSerials) {
let inventoryDetailRecord = fulfillment.getSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail',
line: i
});
for (j = 0; j < allInfo.table[i].pickedSerials.length; j++) {
inventoryDetailRecord.setSublistText({
sublistId: 'inventoryassignment',
fieldId: 'issueinventorynumber',
line: j,
text: allInfo.table[i].pickedSerials[j]
});
inventoryDetailRecord.setSublistValue({
sublistId: 'inventoryassignment',
fieldId: 'quantity',
line: j,
value: 1
});
}
}
}
var itemReceiptId = fulfillment.save();
Boris Yasen
11/07/2023, 3:20 PMBoris Yasen
11/07/2023, 3:22 PMericbirdsall
11/07/2023, 3:24 PMericbirdsall
11/07/2023, 3:25 PMBoris Yasen
11/07/2023, 3:26 PMericbirdsall
11/07/2023, 3:28 PM