system.mes.inventory.validateEditInventoryQuantityRequest
Description
Validates the specified parameters for an edit inventory quantity request and returns any validation errors. This only checks if the quantity edit request can be processed based on the attributes given, without actually modifying the inventory quantity. Use this function to verify your parameters before executing the actual edit operation.
Permissions
This method requires the INVENTORY.READ.VALIDATE permission.
Syntax
system.mes.inventory.validateEditInventoryQuantityRequest(**editInventoryQuantityRequest)
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. |
newQuantity | Double | False | The new quantity to be assigned to the inventory. |
unitOfMeasureSymbol | String | True | The symbol of the unit of measure for the quantity. |
lotIdOrName | String | True | The ID or name of the inventory lot whose quantity is being edited. |
materialIdOrPath | String | False | The ID or path of the material whose quantity is being edited. |
sourceLocationIdOrPath | String | False | The ID or path of the location from the inventory quantity is being edited. |
destinationLotIdOrName | String | True | The ID or name of the inventory lot the adjusted quantity is accounted to, for example the lot a miscounted quantity actually belonged to. Recorded as the lot record's secondary lot so track and trace can draw an edge from the edited lot to this lot. Leave it unset for an ordinary recount that involves no other lot. A name that matches no existing lot creates one. Recorded for traceability only, the named lot's quantities are untouched. See the note below on the direction of the recorded edge. |
destinationMaterialIdOrPath | String | True | The ID or path of the material for the destination lot. Only needed when it differs from materialIdOrPath. |
operationId | String (ULID) | True | The ID of the operation editing the quantity of this inventory. |
inventoryOperationId | String (ULID) | True | The ID of the inventory operation related to this edit inventory quantity action. |
notes | String | True | Notes related to the edit inventory quantity 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 destinationLotIdOrName to record the lot the adjusted quantity is accounted to, so track and
trace can follow the correction from the edited lot into that lot. 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.
The recorded edge always points away from the edited lot, towards the lot named in
destinationLotIdOrName. That reads correctly for a downward correction, where quantity leaves the
edited lot. For an upward correction the material conceptually arrives from the other lot, so the edge
points the opposite way to the real flow. Either record the correcting pair from the other lot's side as
well, or read the edge as an association between the two lots rather than as a direction of flow.
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 edit inventory quantity request object with no initial arguments
editInventoryQuantityRequest = system.mes.inventory.newEditInventoryQuantityRequest()
# Set basic attributes for the new edit inventory quantity request
editInventoryQuantityRequest['materialIdOrPath'] = 'Bottle/Milk'
editInventoryQuantityRequest['sourceLocationIdOrPath'] = 'DairyCo'
editInventoryQuantityRequest['newQuantity'] = 610
# (You can continue setting other properties as needed here)
# Validate edit inventory quantity request parameters
validationErrors = system.mes.inventory.validateEditInventoryQuantityRequest(**editInventoryQuantityRequest)
if len(validationErrors) > 0:
print('Validation errors found:', validationErrors)
else:
print('Edit inventory quantity request parameters are valid.')