Skip to main content

system.mes.unitOfMeasure.convert

Description

Converts the specified amount from one unit of measure to the other.

Syntax

system.mes.unitOfMeasure.convert(amount, from, to)
system.mes.unitOfMeasure.convert(amount, from, to, materialIdOrPath)

Parameters

Method 1: Convert without material context

ParameterTypeNullableDescription
amountDoubleFalseThe amount to convert.
fromStringFalseThe ULID or name of the from unit of measure.
toStringFalseThe ULID or name of the to unit of measure.

Method 2: Convert with material context

ParameterTypeNullableDescription
amountDoubleFalseThe amount to convert.
fromStringFalseThe ULID or name of the from unit of measure.
toStringFalseThe ULID or name of the to unit of measure.
materialIdOrPathStringFalseThe ULID or path of the material associated with the conversion.

Returns

Returns the amount converted.

Example Usage

# Convert the specified amount from one unit of measure to the other.
converted_amount = system.mes.unitOfMeasure.convert(100, 'Pound', 'Kg')

# Output the amount converted to new unit of measure
print(converted_amount)