Skip to main content

system.mes.material.saveMaterialReasonCode

Description

Creates or updates a Material Reason Codes record in the system based on the provided parameters.

Syntax

system.mes.material.saveMaterialReasonCode(**material_reason_code_data)

Parameters

ParameterTypeDescription
lotRecordTypeStringThe action that was taken on a lot.
reasonCodeStringThe unique code identifying the reason for material handling.
descriptionStringThe detailed description of the reason for the material activity.
requireCommentsBooleanIndicates whether additional comments are required when using this reason code.
idString (ULID)The ULID of the material reason code (optional, used for updating an existing material reason code).
notesStringNotes related to the material reason code.
enabledBooleanIndicates if the material reason code 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 reason code.

Code Examples

# Generate the object structure for a new material reason code object, set the initial arguments and save it
new_material_reason_code = system.mes.material.newMaterialReasonCode()
new_material_reason_code['lotRecordType'] = 'CONSUME'
new_material_reason_code['reasonCode'] = 'SCRP001'
material_reason_code_data['requireComments'] = True
saved_material_reason_code = system.mes.material.saveMaterialReasonCode(**new_material_reason_code)

# Output the JSON representation of the saved material reason code
print(saved_material_reason_code)

# Generate the object structure for another new material reason code to update the previous material reason code
material_reason_code_data = system.mes.material.newMaterialReasonCode()

# Set basic attributes for the updated material reason code
material_reason_code_data['id'] = saved_material_reason_code.id
material_reason_code_data['lotRecordType'] = 'CONSUME'
material_reason_code_data['reasonCode'] = 'SCRP001'
material_reason_code_data['description'] = 'Material scrapped due to contamination'
material_reason_code_data['requireComments'] = True
# (You can continue setting other properties as needed here)

# Save the material reason code to update it in the system
updated_material_reason_code = system.mes.material.saveMaterialReasonCode(**material_reason_code_data)

# Output the JSON representation of the updated material reason code
print(updated_material_reason_code)