Skip to main content

system.mes.material.newPropertyValue

Description

Generates an empty non-persisted Material 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.material.newPropertyValue()

Parameters

ParameterTypeDescription
None-This method does not take any parameters.

Returns

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

KeyDefault Value
materialIdnull
materialPropertyIdnull
dataTypeString
valuenull
idnull
notesnull
enabledtrue
spare1null
spare2null
spare3null

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
new_property_value = system.mes.material.newPropertyValue()

# Define property value details
new_property_value['materialId'] = saved_material.id
new_property_value['materialPropertyId'] = saved_property.id
new_property_value['dataType'] = 'Float' # Must be the same data type as the property
new_property_value['value'] = 100
# (You can continue setting other properties as needed here)

# Save the property value
saved_property_value = system.mes.material.savePropertyValue(**new_property_value)

# Output the JSON representation of the saved material property value
print(saved_property_value)