Skip to main content

system.mes.location.newPropertyValue

Description

Generates an empty non-persisted Location Property Values object to provide the structure required by the API to save a new record into the database. This method must be combined with the savePropertyValue method in order to persist the record.

Syntax

system.mes.location.newPropertyValue()

Parameters

ParameterTypeNullableDescription
None--This method does not take any parameters.

Returns

Returns a JSON representation of the newly created location property value object. The following is a list of keys and default values:

KeyDefault Value
locationIdnull
propertyIdnull
dataTypeString
valuenull
idnull
notesnull
enabledtrue
spare1null
spare2null
spare3null

Code Examples

# Generate the object structure for a new location object
newLocation = system.mes.location.newLocation()
newLocation['name'] = 'DairyCo'
savedLocation = system.mes.location.saveLocation(**newLocation)

# Generate the object structure for a new property object
newProperty = system.mes.location.newProperty()
newProperty['name'] = 'Cows'
newProperty['dataType'] = 'Int'
savedProperty = system.mes.location.saveProperty(**newProperty)

# Generate the object structure for a new property value object with no initial arguments
newPropertyValue = system.mes.location.newPropertyValue()

# Define property value details
newPropertyValue['locationId'] = savedLocation.id
newPropertyValue['propertyId'] = savedProperty.id
newPropertyValue['dataType'] = 'Int' # Must be the same data type as the property
newPropertyValue['value'] = 100
# (You can continue setting other properties as needed here)

# Save the property value
savedPropertyValue = system.mes.location.savePropertyValue(**newPropertyValue)

# Output the JSON representation of the saved location property value
print(savedPropertyValue)