Skip to main content

system.mes.unitOfMeasure.validateUnitOfMeasureConversion

Description

Validates the specified parameters for a Unit Of Measure Conversions record and returns any validation errors. This only checks if the unit of measure conversion object can be saved based on the attributes given, without actually creating or modifying the unit of measure conversion. Use this function to verify your parameters before executing a save unit of measure conversion operation.

Syntax

system.mes.unitOfMeasure.validateUnitOfMeasureConversion(**uomc_data)

Parameters

ParameterTypeNullableDescription
fromIdString (ULID)FalseThe unit of measure the conversion is converting from.
toIdString (ULID)FalseThe unit of measure the conversion is converting to.
conversionFactorDoubleFalseThe number used to change the unit of measure from one set to the other.
materialIdString (ULID)TrueThe material associated with the unit of measure conversion.
idString (ULID)TrueThe ULID of the unit of measure conversion (optional, used for updating an existing unit of measure conversion).
notesStringTrueNotes related to the unit of measure conversion.
enabledBooleanTrueIndicates if the unit of measure conversion is active and enabled. Default value is true
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 unit of measure conversion object
uomc_data = system.mes.unitOfMeasure.newUnitOfMeasureConversion()

# Set basic attributes for the new unit of measure conversion
uomc_data['toId'] = '01JCH3T85P-KVCB8ZR5-0B83A3SX'
uomc_data['conversionFactor'] = '0.33'
uomc_data['fromId'] = '01JCH4NB3J-BTERAZ27-QEQQN4ME'
# (You can continue setting other properties as needed here)

# Validate unit of measure conversion parameters
validation_errors = system.mes.unitOfMeasure.validateUnitOfMeasureConversion(**uomc_data)

if len(validation_errors) > 0:
print('Validation errors found:', validation_errors)
else:
print('Unit of measure conversion parameters are valid.')