Skip to main content

system.mes.material.savePropertyValue

Description

Creates or updates a Material Property Values record in the system based on the provided parameters.

Syntax

system.mes.material.savePropertyValue(**propertyValueData)

Parameters

ParameterTypeNullableDescription
materialIdString (ULID)FalseThe ULID of the material.
materialPropertyIdString (ULID)FalseThe ULID of the material property.
dataTypeStringTrueThe data type of the property value. Must be the same as the data type of the property. Default value is String.
valueMixedTrueThe value assigned to the property value if none is provided. The type is mixed as it depends on what dataType is.
idString (ULID)TrueThe ULID of the material property value (optional, for updating an existing property).
notesStringTrueNotes related to the material property value.
enabledBooleanTrueIndicates if the property value 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 material property value.

Code Examples

# Generate the object structure for a new material object
newMaterial = system.mes.material.newMaterial()
newMaterial['materialClassId'] = '01JCH3ENEB-SV2X8B3W-NFY8WZNK'
newMaterial['name'] = '5391537510212'
newMaterial['unitOfMeasureId'] = '01JCH3ENDJ-351WQQPX-WRBNTY4C'
savedMaterial = system.mes.material.saveMaterial(**newMaterial)

# Generate the object structure for a new property object
newProperty = system.mes.material.newProperty()
newProperty['materialClassId'] = '01JCH3ENEB-SV2X8B3W-NFY8WZNK'
newProperty['name'] = 'Density'
newProperty['dataType'] = 'Float'
savedProperty = system.mes.material.saveProperty(**newProperty)

# Generate the object structure for a new property value object with no initial arguments, set the material ID and property ID and save it
newPropertyValue = system.mes.material.newPropertyValue()
newPropertyValue['materialId'] = savedMaterial.id
newPropertyValue['materialPropertyId'] = savedProperty.id
savedPropertyValue = system.mes.material.savePropertyValue(**newPropertyValue)

# Generate the object structure for another new property value object to update the previous material property value
propertyValueData = system.mes.material.newPropertyValue()
propertyValueData['id'] = savedPropertyValue.id
propertyValueData['dataType'] = 'Float' # Must be the same data type as the property
propertyValueData['value'] = 100

# Save the material property value to update it in the system
updatedPropertyValue = system.mes.material.savePropertyValue(**propertyValueData)

# Output the JSON representation of the updated material property value
print(updatedPropertyValue)