Can anyone help me to automatically set inventory ...
# suitescript
u
Can anyone help me to automatically set inventory details on Work Order Completion here is the code
Copy code
// work order completion is transforming in dynamic mode
        woCompletion.selectLine({ sublistId: 'component', line: 0 });
        const componentInventoryDetail = woCompletion.getCurrentSublistSubrecord({ sublistId: 'component', fieldId: 'componentinventorydetail' });
        componentInventoryDetail.selectNewLine({ sublistId: 'inventoryassignment' });
        componentInventoryDetail.setCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'binnumber', value: bin });
        componentInventoryDetail.setCurrentSublistValue({ sublistId: 'inventoryassignment', fieldId: 'quantity', value: quantity });
        componentInventoryDetail.commitLine({ sublistId: 'inventoryassignment' });
        woCompletion.commitLine({ sublistId: 'component' });
        woCompletion.save({
            enableSourcing: true,
            ignoreMandatoryFields: true
        });
		// Error is thrown on woCompletion.save()
		//    	type: "error.SuiteScriptError",
        //    	name: "PLEASE_CONFIGURE_THE_INVENTORY_DETAIL_FOR_1",
        //    	message: "Please configure the inventory detail for line 1."
b
thats pretty much how inventory details work
you will need to share more code