how can i import work order lines with inventory d...
# ask-stanley-ai
h
how can i import work order lines with inventory detail assiging if the line items are duplicated but different lot numbers and quantity
c
AI generated answer (using internal Slack threads):
To import work order lines with inventory detail assigning if the line items are duplicated but different lot numbers and quantity, you can use the
record.transform
method to transform a Work Order into a Work Order Completion. Then, you can use the
getSubrecord
method to get the
inventorydetail
subrecord and use the
setSublistValue
method to set the
quantity
and
receiptinventorynumber
(lot number) for each line item. Here is a sample code snippet:
Copy code
javascript
var workOrderCompRec = record.transform({
    fromType: record.Type.WORK_ORDER,
    fromId: workOrderId,
    toType: record.Type.WORK_ORDER_COMPLETION,
    isDynamic: false
});

var inventoryDetail = workOrderCompRec.getSubrecord({fieldId: 'inventorydetail'});
for (var j = 0; j < inventoryDetails.length; j++) {
    if (inventoryDetails[j].quantity) {        
        try {
            inventoryDetail.setSublistValue({
                sublistId: 'inventoryassignment',
                fieldId: 'quantity',
                value: inventoryDetails[j].quantity,
                line: j
            });
            inventoryDetail.setSublistValue({
                sublistId: 'inventoryassignment',
                fieldId: 'receiptinventorynumber',
                value: inventoryDetails[j].lotNumber,
                line: j
            });
        } catch (e) {            
            log.error('ERROR SETTING INV DETAIL', e);
        }
    }
}
In this code,
inventoryDetails
is an array of objects, each representing a line item with properties
quantity
and
lotNumber
. This array can be created based on the CSV file you are importing. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816184163
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815147161
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814220607
Please provide your feedback on this answer.