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(**property_value_data)

Parameters

ParameterTypeDescription
materialIdString (ULID)The ULID of the material.
materialPropertyIdString (ULID)The ULID of the material property.
dataTypeStringThe data type of the property value. Must be the same as the data type of the property.
valueMixedThe value assigned to the property value if none is provided. The type is mixed as it depends on what dataType is.
idString (ULID)The ULID of the material property value (optional, for updating an existing property).
notesStringNotes related to the material property value.
enabledBooleanIndicates if the property value is active and enabled.
spare1StringAdditional field for user-defined context.
spare2StringAdditional field for user-defined context.
spare3StringAdditional 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
new_material = system.mes.material.newMaterial()
new_material['materialClassId'] = '01JCH3ENEB-SV2X8B3W-NFY8WZNK'
new_material['name'] = '5391537510212'
new_material['unitOfMeasureId'] = '01JCH3ENDJ-351WQQPX-WRBNTY4C'
saved_material = system.mes.material.saveMaterial(**new_material)

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

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

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

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

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