Skip to main content

system.mes.inventory.validateConsumeRequest

Validates the specified parameters for a consume request and returns any validation errors. This only checks if the consume request can be processed based on the attributes given, without actually performing the consumption. Use this function to verify your parameters before executing the actual consume operation.

Syntax

system.mes.inventory.validateConsumeRequest(**consume_request)

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.
quantityDoubleFalseThe quantity to consume from the location.
unitOfMeasureSymbolStringTrueThe symbol of the unit of measure for the quantity.
lotIdOrNameStringTrueThe ID or name of the inventory lot that will be consuming the given lot.
materialIdOrPathStringFalseThe ID or path of the material being consumed.
sourceLocationIdOrPathStringFalseThe ID or path of the location from which inventory will be consumed.
consumingLotIdOrNameStringTrueThe ID or name of the inventory lot from which the material is being consumed.
destinationLocationIdOrPathStringTrueThe ID or path of the location the consumed inventory goes to.
createIfNotExistsBooleanFalseIndicates whether the system should create the lot if it does not exist. Default value is false.
operationIdString (ULID)TrueThe ID of the operation consuming this inventory.
inventoryOperationIdString (ULID)TrueThe ID of the inventory operation related to this consume action.
productionOrderIdOrNameStringTrueThe ID or name of the production order associated with the consumption.
materialReasonCodeIdString (ULID)TrueThe ID of the material reason code to add additional context.
startDateInstantFalseThe start date and time of the consumption. Default value is Current Instant.
endDateInstantTrueThe end date and time of the consumption.
ongoingBooleanFalseIndicates whether this request is ongoing. Default value is false.
inventoryNameStringTrueThe name of the inventory.
notesStringTrueNotes related to the consume request.
spare1StringTrueAdditional field for user-defined context.
spare2StringTrueAdditional field for user-defined context.
spare3StringTrueAdditional field for user-defined context.

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 consume request object with no initial arguments
consume_request = system.mes.inventory.newConsumeRequest()

# Set basic attributes for the new consume request
consume_request['materialIdOrPath'] = 'Bottle/Milk'
consume_request['sourceLocationIdOrPath'] = 'DairyCo'
consume_request['quantity'] = 610
consume_request['createIfNotExists'] = True
# (You can continue setting other properties as needed here)

# Validate consume request parameters
validation_errors = system.mes.inventory.validateConsumeRequest(**consume_request)

if len(validation_errors) > 0:
print('Validation errors found:', validation_errors)
else:
print('Consume request parameters are valid.')