Skip to main content

system.mes.inventory.newConsumeRequest

Generates an empty non-persisted Consume Request to provide the structure required by the API to save a new record into the database. This method must be combined with the consume method in order to persist the record.

Syntax

system.mes.inventory.newConsumeRequest()

Parameters

ParameterTypeDescription
None-This method does not take any parameters.

Returns

Returns a JSON representation of the newly created Consume Request object. The following is a list of keys and default values:

KeyDefault Value
typeCONSUME
quantitynull
unitOfMeasureSymbolnull
lotIdOrNamenull
materialIdOrPathnull
sourceLocationIdOrPathnull
consumingLotIdOrNamenull
destinationLocationIdOrPathnull
createIfNotExistsfalse
operationIdnull
productionOrderIdOrNamenull
materialReasonCodeIdnull
startDateCurrent Time
endDatenull
ongoingfalse
inventoryNamenull
notesnull
spare1null
spare2null
spare3null

Code Examples

# Generate the object structure for a new consume request object with no initial arguments
new_request = system.mes.inventory.newConsumeRequest()

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

# Consume the request
consumed_request = system.mes.inventory.consume(**new_request)

# Output the JSON representation of the consumed request
print(consumed_request)