system.mes.inventory.validateUnconsumeRequest
Description
Validates the specified parameters for an unconsume request and returns any validation errors. This only checks if the unconsume request can be processed based on the attributes given, without actually performing the unconsumption. Use this function to verify your parameters before executing the actual unconsume operation.
Permissions
This method requires the INVENTORY.READ.VALIDATE permission.
Syntax
system.mes.inventory.validateUnconsumeRequest(**unconsumeRequest)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
type | String | True | The type of request defined by the LotRecordType Enum. It is internally set and must not be modified, as changes may break functionality. |
quantity | Double | False | The quantity to unconsume from the location. |
unitOfMeasureSymbol | String | True | The symbol of the unit of measure for the quantity. |
lotIdOrName | String | True | The ID or name of the inventory lot being unconsumed. |
materialIdOrPath | String | False | The ID or path of the material being unconsumed. |
destinationLocationIdOrPath | String | False | The ID or path of the location the unconsumed inventory goes to. |
sourceLotIdOrName | String | True | The ID or name of the inventory lot the material is being unconsumed from, that is, the lot that had consumed it. Recorded as the lot record's secondary lot so track and trace can draw an edge from that lot to the lot being unconsumed into. A name that matches no existing lot creates one. Recorded for traceability only, neither lot's quantities change. |
sourceMaterialIdOrPath | String | True | The ID or path of the material for the source lot. Only needed when it differs from materialIdOrPath. |
sourceLocationIdOrPath | String | True | The ID or path of the location where the inventory is being unconsumed from. |
operationId | String (ULID) | True | The ID of the operation unconsuming this inventory. |
inventoryOperationId | String (ULID) | True | The ID of the inventory operation related to this unconsume action. |
productionOrderIdOrName | String | True | The ID or name of the production order associated with the unconsumption. |
materialReasonCodeId | String (ULID) | True | The ID of the material reason code to add additional context. |
startDate | Instant | False | The start date and time of the unconsumption. Default value is Current Instant. |
endDate | Instant | True | The end date and time of the unconsumption. |
ongoing | Boolean | False | Indicates whether this request is ongoing. Default value is false. |
inventoryName | String | True | The name of the inventory. |
notes | String | True | Notes related to the unconsume request. |
spare1 | String | True | Additional field for user-defined context. |
spare2 | String | True | Additional field for user-defined context. |
spare3 | String | True | Additional field for user-defined context. |
Name sourceLotIdOrName to record the lot the material is coming back from, so track and trace can
follow it from that lot into the lot being unconsumed into. The link is recorded on the inventory lot record as its secondary lot, and is what
getLotTraceGraph follows when it draws the
genealogy. Naming a lot that does not exist yet creates it. No quantity arithmetic changes, the link
is recorded for traceability only.
Returns
Returns a JSON object where keys are field names and values are lists of validation violation messages.
Code Examples
# Generate the object structure for a new unconsume request object with no initial arguments
unconsumeRequest = system.mes.inventory.newUnconsumeRequest()
# Set basic attributes for the new unconsume request
unconsumeRequest['materialIdOrPath'] = 'Bottle/Milk'
unconsumeRequest['destinationLocationIdOrPath'] = 'DairyCo'
unconsumeRequest['quantity'] = 610
# (You can continue setting other properties as needed here)
# Validate unconsume request parameters
validationErrors = system.mes.inventory.validateUnconsumeRequest(**unconsumeRequest)
if len(validationErrors) > 0:
print('Validation errors found:', validationErrors)
else:
print('Unconsume request parameters are valid.')