Skip to main content

system.mes.inventory.operation.saveInventoryOperation

Description

Creates or updates an Inventory Operations record in the system based on the provided parameters.

Syntax

system.mes.inventory.operation.saveInventoryOperation(**inventory_operation_data)

Parameters

ParameterTypeNullableDescription
operationIdString (ULID)TrueThe ULID of the operation associated with this inventory operation.
operationNameStringTrueThe name of the operation associated with this inventory operation.
nameStringFalseThe name of the inventory operation.
statusStringTrueThe status of the inventory operation.
currentRecordIdString (ULID)TrueThe ULID of the current inventory lot record associated with this inventory operation.
operationTypeStringFalseThe type of inventory operation. Default value is CONSUME.
triggerSourceStringFalseThe trigger evaluation strategy. Default value is EXPRESSION.
startTriggerExpressionStringTrueThe Ignition expression to trigger the start of the operation.
startTriggerTypeStringTrueThe trigger type when starting the operation. Default RISING_EDGE.
stopTriggerExpressionStringTrueThe Ignition expression to trigger the end of the operation.
stopTriggerTypeStringTrueThe trigger type when stopping the operation. Default FALLING_EDGE.
sourceLocationIdString (ULID)TrueThe ULID of the source location.
sourceLocationPathStringTrueThe path of the source location.
destinationLocationIdString (ULID)TrueThe ULID of the destination location.
destinationLocationPathStringTrueThe path of the destination location.
materialSourceStringFalseThe strategy used for resolving material. Default value is STATIC.
materialIdString (ULID)TrueThe ULID of the material (if materialSource is STATIC).
materialPathStringTrueThe path of the material (if materialSource is STATIC).
materialExpressionStringTrueThe Ignition expression resolving material (if materialSource is EXPRESSION). Must return an id or path.
secondaryMaterialIdString (ULID)TrueThe ULID of the secondary material (optional, used for certain operation types).
secondaryMaterialPathStringTrueThe path of the secondary material.
primaryLotResolutionStrategyStringFalseStrategy to resolve the primary lot code. Default AUTO_GENERATE.
secondaryLotResolutionStrategyStringFalseStrategy to resolve the secondary lot code. Default AUTO_GENERATE.
primaryLotCodeExpressionStringTrueExpression resolving primary lot code (if strategy is EXPRESSION).
secondaryLotCodeExpressionStringTrueExpression resolving secondary lot code (if strategy is EXPRESSION).
createLotIfNotFoundBooleanTrueCreate the lot if not found. Only used for certain operation types (e.g. CONSUME).
inventoryNameResolutionStrategyStringFalseStrategy to resolve inventory name. Default value is STATIC.
inventoryNameStringTrueThe inventory name (if strategy is STATIC).
inventoryNameExpressionStringTrueExpression resolving inventory name (if strategy is EXPRESSION).
quantitySourceStringFalseSource for quantity. Default value is EXPRESSION.
quantityExpressionStringTrueQuantity expression (required when quantitySource = EXPRESSION).
quantityCalcTypeStringFalseQuantity calculation type (DELTA or DIRECT). Default DELTA.
quantityOverflowValueDoubleTrueOverflow rollover threshold when using a rising counter with DELTA semantics.
unitOfMeasureIdString (ULID)TrueULID of the unit of measure.
unitOfMeasureNameStringTrueName of the unit of measure.
unitOfMeasureResolutionStrategyStringFalseStrategy for unit of measure. Default STATIC.
reasonCodeIdString (ULID)TrueULID of the material reason code.
reasonCodeNameStringTrueName of the material reason code.
incrementProductionOrderCountBooleanFalseIncrement production order quantity for shipping/producing. Default false.
idString (ULID)TrueThe ULID of the inventory operation (supply to update).
notesStringTrueNotes related to the inventory operation.
enabledBooleanTrueIndicates if the inventory operation is enabled. Default true.
spare1StringTrueAdditional field for user context.
spare2StringTrueAdditional field for user context.
spare3StringTrueAdditional field for user context.

Returns

Returns a JSON representation of the saved inventory operation.

Code Examples

# Generate the object structure for a new inventory operation object, set the initial arguments and save it
new_inventory_operation = system.mes.inventory.operation.newInventoryOperation()
new_inventory_operation['name'] = 'Lids'
new_inventory_operation['sourceLocationId'] = '01JD7M94CJ-HPEQEJ1F-QA8EQ6VE'
saved_inventory_operation = system.mes.inventory.operation.saveInventoryOperation(**new_inventory_operation)

print(saved_inventory_operation)

# Update existing inventory operation
inventory_operation_data = system.mes.inventory.operation.newInventoryOperation()
inventory_operation_data['id'] = saved_inventory_operation.id
inventory_operation_data['name'] = 'Lids'
inventory_operation_data['sourceLocationId'] = '01JD7M94CJ-HPEQEJ1F-QA8EQ6VE'
inventory_operation_data['materialId'] = '01JCH3GRA3-5ZYFZV5V-RW3FKFJX'
inventory_operation_data['unitOfMeasureId'] = '01JCH3T85P-KVCB8ZR5-0B83A3SX'
updated_inventory_operation = system.mes.inventory.operation.saveInventoryOperation(**inventory_operation_data)

print(updated_inventory_operation)