Skip to main content

system.mes.oee.validateDowntimeReason

Description

Validates an OEE Downtime Reason object without saving it. This is useful for checking if a downtime reason is valid before attempting to save it.

Permissions

This method requires the OEE.READ.VALIDATE permission.

Syntax

system.mes.oee.validateDowntimeReason(**reasonData)

Parameters

An unpacked dictionary of OeeDowntimeReasonDTO fields.

ParameterTypeNullableDescriptionDefault Value
idStringTrueThe id of the Downtime Reasonnull
locationIdStringTrueIdentifier of the associated location where this downtime reason appliesnull
locationPathStringTruePath of the associated location where this downtime reason appliesnull
parentIdStringTrueIdentifier of the parent downtime reason, if applicablenull
codeIntegerFalseUnique fault code associated with this downtime reason0
nameStringFalseName of the downtime reasonnull
descriptionStringTrueDescription of the downtime reasonnull
pathStringTruePath representation of the downtime reason within a hierarchical structurenull
notesStringTrueNotes associated with the Downtime Reasonnull
enabledbooleanTrueIndicates whether the Downtime Reason is enabledtrue
spare1StringTrueExtra field 1null
spare2StringTrueExtra field 2null
spare3StringTrueExtra field 3null

Returns

A JSON object containing validation results. If the object is empty, validation passed. If it contains entries, the keys are the field names and the values are lists of validation error messages.

Code Examples

# Create a new downtime reason object
newReason = system.mes.oee.newDowntimeReason()

# Set some attributes (leaving required fields blank to trigger validation errors)
newReason['enabled'] = True

# Validate the downtime reason
validationErrors = system.mes.oee.validateDowntimeReason(**newReason)

if not validation_errors:
print "Validation passed. Downtime reason is valid."
else:
print "Validation failed. Errors:"
for field, errors in validationErrors.items():
print " - {}: {}".format(field, ", ".join(errors))

# Example of a valid reason
validReason = system.mes.oee.newDowntimeReason()
validReason['name'] = 'Mechanical'
validReason['code'] = 100
# ... other required fields ...

errors = system.mes.oee.validateDowntimeReason(**validReason)
if not errors:
print "\nThe second downtime reason is valid."