system.mes.unitOfMeasure.doesConversionExist
Description
Checks if a Unit Of Measure Conversions object with the given parameters exists.
The match is exact on all three parameters. Direction and material scope are both part of a conversion's identity, so:
- A stored
Pound -> Kilogramconversion does not makeKilogram -> Poundexist. Both directions may be stored as separate conversions. - A global conversion (a
materialIdofNone) does not make a material-scoped conversion for the same pair exist, and vice versa.
To ask the broader question "can I convert between these two units" - which also follows the reverse direction, the
global fallback, and multi-hop conversion paths - use convert and handle the exception it raises when
no conversion path exists.
Permissions
This method requires the UNIT_OF_MEASURE.READ.GET permission.
Syntax
system.mes.unitOfMeasure.doesConversionExist(fromIdOrName, toIdOrName, materialId)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
fromIdOrName | String | False | The ULID or name of the from unit of measure to check. |
toIdOrName | String | False | The ULID or name of the to unit of measure to check. |
materialId | String | True | The ULID or path of the material associated with the conversion. None checks the global conversion. |
Returns
Returns a boolean indicating whether the unit of measure conversion exists.
Code Examples
# Check whether the unit of measure conversion exists
uomcExists = system.mes.unitOfMeasure.doesConversionExist('Pound', 'Kilogram', '01JCH3TP3Y-4B080WHN-MSR8RVP5')
# Output the boolean result
print(uomcExists)
# The reverse direction is a separate conversion, so this can be False even when the call above is True
reverseExists = system.mes.unitOfMeasure.doesConversionExist('Kilogram', 'Pound', '01JCH3TP3Y-4B080WHN-MSR8RVP5')
print(reverseExists)