Skip to main content

system.mes.inventory.validateScrapRequest

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

Syntax

system.mes.inventory.validateScrapRequest(**scrap_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 scrap from the location.
unitOfMeasureSymbolStringTrueThe symbol of the unit of measure for the quantity.
lotIdOrNameStringTrueThe ID or name of the inventory lot that will be scrapped.
materialIdOrPathStringFalseThe ID or path of the material being scrapped.
sourceLocationIdOrPathStringFalseThe ID or path of the location from which inventory will be scrapped.
operationIdString (ULID)TrueThe ID of the operation scrapping this inventory.
inventoryOperationIdString (ULID)TrueThe ID of the inventory operation related to this scrap action.
productionOrderIdOrNameStringTrueThe ID or name of the production order associated with the scrap.
materialReasonCodeIdString (ULID)TrueThe ID of the material reason code to add additional context.
startDateInstantFalseThe start date and time of the scrap. Default value is Current Instant.
endDateInstantTrueThe end date and time of the scrap.
ongoingBooleanFalseIndicates whether this request is ongoing. Default value is false.
inventoryNameStringTrueThe name of the inventory the scrapped inventory goes to.
notesStringTrueNotes related to the scrap 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 scrap request object with no initial arguments
scrap_request = system.mes.inventory.newScrapRequest()

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

# Validate scrap request parameters
validation_errors = system.mes.inventory.validateScrapRequest(**scrap_request)

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