Hi Everyone I am facing this error when i set quan...
# suitescript
a
Hi Everyone I am facing this error when i set quantity of work order completion record, This only happens when i create work order completion (with backflush) using SS 2.0 , i can successfully create work order completion (with backflush) using UI ,with exact same quantity to build. Any help would be appreciated . Thanks {"type":"error.SuiteScriptError","name":"USER_ERROR","message":"Please enter an inventory status for each line.","stack":["anonymous(N/serverRecordService)","beforeLoad(/SuiteScripts/UE_test.js:84)"],"cause":{"type":"internal error","code":"USER_ERROR","details":"Please enter an inventory status for each line.","userEvent":"beforeload","stackTrace":["anonymous(N/serverRecordService)","beforeLoad(/SuiteScripts/UE_test.js:84)"],"notifyOff":false},"id":"","notifyOff":false,"userFacing":false}
var workOrderCompletion = record.transform({
fromType: record.Type.WORK_ORDER, fromId: 29529, toType: record.Type.WORK_ORDER_COMPLETION, isDynamic: true }); workOrderCompletion.setValue('isbackflush', true); log.audit('workOrderCompletion ',workOrderCompletion); //Calculate Quantity to Build and Scrap based on Parent WO ratio qtyToBuild = '0.4008'; workOrderCompletion.setValue('quantity', qtyToBuild); //as per stack trace , error here log.emergency('Quantity Value ',workOrderCompletion.getValue('quantity')); var inventoryDetailSubRecord = workOrderCompletion.getSubrecord({ fieldId: 'inventorydetail' }); log.emergency('Quantity Value ',inventoryDetailSubRecord.getValue('quantity')); inventoryDetailSubRecord.selectNewLine({ sublistId: 'inventoryassignment', }); inventoryDetailSubRecord.setCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'receiptinventorynumber', value: serialLotNumberHeader }); inventoryDetailSubRecord.setCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'quantity', value: qtyToBuild }); inventoryDetailSubRecord.commitLine({ sublistId: 'inventoryassignment' }); log.emergency('serialLotNumberHeader ', serialLotNumberHeader); log.emergency('qtyToBuild ', qtyToBuild); completionNo = workOrderCompletion.save(); log.emergency('Completion ID ', completionNo);
@battk Do you have any idea sir ?
b
set the inventory status like the error is telling you to
a
I am already setting inventory detail on header level, actually this error is thrown when i set build quantity , This line workOrderCompletion.setValue('quantity', qtyToBuild); //as per stack trace , error here am i missing something ? where can i find inventory status field
Weird thing is that i dont face this error via UI ,
b
its an inventory detail field
the ui will default it to the good status, scripts will not
keep in mind the inventory detail is at the component and body level
a
i tried to set inventorystatus but it doesnt work Actually this error is thrown even before i set inventory detail , its thrown on *workOrderCompletion.setValue('quantity',*0.4008 )
b
what did the code look like
a
define(['N/search', 'N/record'], function (search, record) { function beforeLoad(context) { try { log.debug('beforeLoad Context Type is ', context.type); var workOrderCompletion = record.transform({ fromType: record.Type.WORK_ORDER, fromId: 29529, toType: record.Type.WORK_ORDER_COMPLETION, isDynamic: true }); workOrderCompletion.setValue('isbackflush', true); log.audit('workOrderCompletion ',workOrderCompletion); //Calculate Quantity to Build and Scrap based on Parent WO ratio qtyToBuild = '0.4008'; workOrderCompletion.setValue('quantity', qtyToBuild); log.emergency('Quantity Value ',workOrderCompletion.getValue('quantity')); var inventoryDetailSubRecord = workOrderCompletion.getSubrecord({ fieldId: 'inventorydetail' }); log.emergency('Quantity Value ',inventoryDetailSubRecord.getValue('quantity')); inventoryDetailSubRecord.selectNewLine({ sublistId: 'inventoryassignment', }); inventoryDetailSubRecord.setCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'receiptinventorynumber', value: '123456' }); inventoryDetailSubRecord.setCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'inventorystatus', value: '1' }); inventoryDetailSubRecord.setCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'quantity', value: qtyToBuild }); inventoryDetailSubRecord.commitLine({ sublistId: 'inventoryassignment' }); // log.emergency('serialLotNumberHeader ', serialLotNumberHeader); log.emergency('qtyToBuild ', qtyToBuild); completionNo = workOrderCompletion.save(); log.emergency('Completion ID ', completionNo); } catch (e) { log.debug('Error beforeSubmit ', e); } } return { beforeLoad: beforeLoad }; });
error is thrown even on setValue , when i set quantity to build
b
and the component inventory details?
a
its coming from child work orders , autopopulated
i complete child work orders and then trying to complete this specific work order
b
set it anyways
a
sure , let me try
b
im not even sure how you set inventory details on work orders