Skip to main content

system.mes.location.saveProperty

Description

Creates or updates a Location Properties record in the system based on the provided parameters.

Syntax

system.mes.location.saveProperty(**property_data)

Parameters

ParameterTypeNullableDescription
nameStringFalseThe name of the location property.
descriptionStringTrueA description of the location property.
dataTypeStringFalseThe data type of the property (e.g., Integer, String, Float). Default value is String.
lowLimitDoubleTrueThe minimum value allowed for a numerical property.
highLimitDoubleTrueThe maximum value allowed for a numerical property.
formatStringTrueThe format of the property, if applicable.
unitOfMeasureIdString (ULID)TrueThe ULID of the unit of measure for this property.
unitOfMeasureNameStringTrueThe name of the unit of measure for the property. For display purposes only.
unitOfMeasureSymbolStringTrueThe symbol of the unit of measure for the property. For display purposes only.
optionsStringTrueList of possible values for the property (e.g., "[option1, option2]").
nullableBooleanFalseDefines if the property can accept null values. Default value is false.
defaultValueMixedTrueThe default value assigned to the property if none is provided. The type is mixed as it depends on what dataType is.
idString (ULID)TrueThe ULID of the location property (optional, for updating an existing property).
notesStringTrueNotes related to the location property.
enabledBooleanFalseIndicates if the property 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 representation of the saved location property.

Code Examples

# Generate the object structure for a new property object, set the name and save it
new_property = system.mes.location.newProperty()
new_property['name'] = 'Temperature'
saved_property = system.mes.location.saveProperty(**new_property)

# Output the JSON representation of the saved property
print(saved_property)

# Generate the object structure for another new property object to update the previous property
property_data = system.mes.location.newProperty()

# Define property attributes
property_data['id'] = saved_property.id
property_data['name'] = 'Temperature'
property_data['dataType'] = 'Float'
property_data['lowLimit'] = -20
property_data['highLimit'] = 50
property_data['unitOfMeasureId'] = '01JAP8RJBN-4VYZUKE1-LY2QHV8X'
property_data['nullable'] = False
property_data['defaultValue'] = 20.0
# (You can continue setting other properties as needed here)

# Save the location property to update it in the system
updated_property = system.mes.location.saveProperty(**property_data)

# Output the JSON representation of the updated location property
print(updated_property)