Skip to main content
Version: V2 (Ignition 8.1)

system.mes.inventory.editInventoryQuantity

Description​

Edit inventory quantity from the MES based on the provided parameters.

Permissions​

This method requires the INVENTORY.WRITE.EDIT permission.

Syntax​

system.mes.inventory.editInventoryQuantity(**editInventoryQuantityRequest)

Parameters​

ParameterTypeNullableDescription
typeStringTrueThe type of request defined by the LotRecordType Enum. It is internally set and must not be modified, as changes may break functionality.
newQuantityDoubleFalseThe new quantity to be assigned to the inventory.
unitOfMeasureSymbolStringTrueThe symbol of the unit of measure for the quantity.
lotIdOrNameStringTrueThe ID or name of the inventory lot whose quantity is being edited.
materialIdOrPathStringFalseThe ID or path of the material whose quantity is being edited.
sourceLocationIdOrPathStringFalseThe ID or path of the location from the inventory quantity is being edited.
destinationLotIdOrNameStringTrueThe 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.
destinationMaterialIdOrPathStringTrueThe ID or path of the material for the destination lot. Only needed when it differs from materialIdOrPath.
operationIdString (ULID)TrueThe ID of the operation editing the quantity of this inventory.
inventoryOperationIdString (ULID)TrueThe ID of the inventory operation related to this edit inventory quantity action.
notesStringTrueNotes related to the edit inventory quantity request.
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.
Lot genealogy

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.

Edge direction on an upward correction

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 representation of an inventory lot record for an Edit Inventory Quantity Request.

NameTypeDescription
lotRecordTypeStringThe type of change for the record.
inventoryLotIdString (ULID)The ULID of the primary inventory lot for the inventory lot record.
inventoryLotNameStringThe name of the primary inventory lot for the inventory lot record.
secondaryInventoryLotIdString (ULID)The ULID of the secondary inventory lot for the inventory lot record.
secondaryInventoryLotNameStringThe name of the secondary inventory lot for the inventory lot record.
operationRecordIdString (ULID)The ULID of the operation record for the inventory lot record.
inventoryOperationIdString (ULID)The ULID of the inventory operation for the inventory lot record.
inventoryOperationNameStringThe name of the inventory operation for the inventory lot record.
productionOrderIdString (ULID)The ULID of the production order for the inventory lot record.
productionOrderNameStringThe name of the production order for the inventory lot record.
materialReasonCodeIdString (ULID)The ULID of the material reason code for the inventory lot record.
materialReasonCodeNameStringThe name of the material reason code for the inventory lot record.
sourceLocationIdString (ULID)The source location of the inventory or lot being operated.
sourceLocationNameStringThe name of the source location of the inventory or lot being operated.
sourceLocationPathStringThe path of the source location of the inventory or lot being operated.
destinationLocationIdString (ULID)The destination location of the inventory or lot being operated.
destinationLocationNameStringThe name of the destination location of the inventory or lot being operated.
destinationLocationPathStringThe path of the destination location of the inventory or lot being operated.
lotStatusStringThe status of the inventory lot.
quantityDoubleThe quantity of units being changed depending on the lotRecordType.
unitOfMeasureIdStringThe ID of the unit of measure for the quantity.
unitOfMeasureNameStringThe name of the unit of measure for the quantity.
unitOfMeasureSymbolStringThe symbol of the unit of measure for the quantity.
startDateInstantThe beginning timestamp of the inventory lot change.
endDateInstantThe end timestamp of the inventory lot change.
statusStringThe status of the inventory lot record (e.g. Running, Completed, Faulted).
durationLongThe duration in seconds.
shiftRecordIdStringThe shift the inventory lot record occurred in.
idString (ULID)The ULID of the inventory lot record (optional, used for updating an existing inventory lot record).
notesStringNotes related to the inventory lot.
enabledBooleanIndicates if the inventory lot is active and enabled.
spare1StringAdditional field for user-defined context.
spare2StringAdditional field for user-defined context.
spare3StringAdditional field for user-defined context.

Code Examples​

# Generate the object structure for a new edit inventory quantity request object with no initial arguments
newRequest = system.mes.inventory.newEditInventoryQuantityRequest()

# Set basic attributes for the new edit inventory quantity request
newRequest['materialIdOrPath'] = 'Bottle/Milk'
newRequest['sourceLocationIdOrPath'] = 'DairyCo'
newRequest['newQuantity'] = 610
# (You can continue setting other properties as needed here)

# Edit the quantity of the inventory
editInventoryLotRecord = system.mes.inventory.editInventoryQuantity(**newRequest)

# Output the JSON representation of the lot record of the edit quantity action
print(editInventoryLotRecord)