Why is my work order close quantity 0 but there is...
# ask-stanley-ai
k
Why is my work order close quantity 0 but there is a completed quantity listed in the work order completion
c
AI generated answer (using internal Slack threads):
The 'Completed Quantity' in a Work Order Completion is the quantity of the item that has been produced and completed. This is different from the 'Close Quantity' in a Work Order, which refers to the quantity of the item that is closed and no longer in production. If your 'Close Quantity' is 0 but there is a 'Completed Quantity' listed in the Work Order Completion, it could be due to a few reasons: 1. The Work Order is not yet fully closed: The 'Close Quantity' will remain 0 until the Work Order is fully closed. Even if some quantity has been completed, the 'Close Quantity' will not reflect this until the entire Work Order is closed. 2. Partial completion of Work Order: It is possible to post a completion or assembly build for less than the Work Order quantity. In this case, the 'Completed Quantity' will reflect the partial quantity that has been completed, but the 'Close Quantity' will remain 0 until the entire Work Order is closed. 3. Incorrect setting of quantities in SuiteScript: If you are using SuiteScript to create a Work Order Completion, make sure to set the 'completedquantity' and 'quantity' correctly. The 'completedquantity' should be set to the quantity of the item that has been produced and completed, and the 'quantity' should be set to the quantity of the item that is to be produced. Also, ensure to set the quantity on the body level of the inventory detail before creating the inventory detail. Here is a sample code snippet:
Copy code
javascript
var objWorkOrderCompletion = record.transform({
  fromType: record.Type.WORK_ORDER,
  fromId: strProcessingWorkOrder,
  toType: record.Type.WORK_ORDER_COMPLETION,
  isDynamic: true,
});
var subrec = objWorkOrderCompletion.getSubrecord('inventorydetail');
var numberLinesSubrecord = subrec.getLineCount('inventoryassignment');
              
subrec.selectNewLine('inventoryassignment');
var intItemWOQty = 0;
intItemWOQty = objWorkOrderCompletion.getValue('orderquantity');
objWorkOrderCompletion.setValue('completedquantity', Number(intItemWOQty - intLossSumQuantity));
objWorkOrderCompletion.setValue('quantity',  Number(intItemWOQty - intLossSumQuantity));
subrec.setCurrentSublistValue({
  sublistId: 'inventoryassignment',
  fieldId: 'quantity',
  value: totalQ,
});
subrec.commitLine({ sublistId: 'inventoryassignment' });
var completionId = objWorkOrderCompletion.save();
****** 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.83699894
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836962938
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.827034593
Please provide your feedback on this answer.