system.mes.unitOfMeasure.saveUnitOfMeasure
Description
Creates or updates a Units Of Measure record in the system based on the provided parameters.
Syntax
system.mes.unitOfMeasure.saveUnitOfMeasure(**uom_data)
Parameters
Parameter | Type | Description |
---|---|---|
name | String | The name of the unit of measure. |
symbol | String | The symbol of the unit of measure. |
id | String (ULID) | The ULID of the unit of measure (optional, used for updating an existing unit of measure). |
notes | String | Notes related to the unit of measure. |
enabled | Boolean | Indicates if the unit of measure is active and enabled. |
spare1 | String | Additional field for user-defined context. |
spare2 | String | Additional field for user-defined context. |
spare3 | String | Additional field for user-defined context. |
Returns
Returns a JSON representation of the saved unit of measure.
Code Examples
# Generate the object structure for a new unit of measure object, set the parameters and save it
new_uom = system.mes.unitOfMeasure.newUnitOfMeasure()
new_uom['name'] = 'Pound'
new_uom['symbol'] = 'lb'
saved_uom = system.mes.unitOfMeasure.saveUnitOfMeasure(**new_uom)
# Output the JSON representation of the saved unit of measure
print(saved_uom)
# Generate the object structure for another new unit of measure object to update the previous unit of measure
uom_data = system.mes.unitOfMeasure.newUnitOfMeasure()
# Set basic attributes for the updated unit of measure
uom_data['id'] = saved_uom.id
uom_data['name'] = 'Pound'
uom_data['symbol'] = 'lb'
uom_data['notes'] = 'The weight'
# (You can continue setting other properties as needed here)
# Save the unit of measure to update it in the system
updated_uom = system.mes.unitOfMeasure.saveUnitOfMeasure(**uom_data)
# Output the JSON representation of the updated unit of measure
print(updated_uom)