Skip to main content
Version: V3 (Ignition 8.3)

system.mes.unitOfMeasure.addConversion

Description​

Adds a Unit Of Measure Conversions record from one unit of measure to another for the specified material with the specified conversion factor.

Permissions​

This method requires the UNIT_OF_MEASURE.WRITE.SAVE permission.

Syntax​

system.mes.unitOfMeasure.addConversion(fromIdOrName, toIdOrName, conversionFactor, materialId)

Parameters​

ParameterTypeNullableDescription
fromIdOrNameStringFalseThe ULID or name of the from unit of measure to check.
toIdOrNameStringFalseThe ULID or name of the to unit of measure to check.
conversionFactorDoubleFalseThe conversion factor between the units of measure.
materialIdString (ULID)TrueThe ULID of the material associated with the conversion.

The check against existing conversions is exact on from, to and material. A stored Pound -> Kg conversion does not block adding Kg -> Pound, and a global conversion does not block adding a material-scoped one for the same pair. Adding a conversion that already exists with a different conversion factor raises an exception - edit the existing conversion with saveUnitOfMeasureConversion instead.

Returns​

Returns a JSON representation of the added unit of measure conversion object.

Code Examples​

# Add a unit of measure conversion using the parameters
addUomc = system.mes.unitOfMeasure.addConversion('Pound', 'Kg', 0.33, '01JCH3TP3Y-4B080WHN-MSR8RVP5')

# Output the JSON representation of the added unit of measure conversion
print(addUomc)