system.mes.equipment.validateEquipment
Description
Validates the specified parameters for an Equipment record and returns any validation errors. This only checks if the equipment object can be saved based on the attributes given, without actually creating or modifying the equipment. Use this function to verify your parameters before executing operations that create or modify equipment.
Permissions
This method requires the EQUIPMENT.READ.VALIDATE permission.
Syntax
system.mes.equipment.validateEquipment(**equipmentData)
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
name | String | False | The name of the equipment. |
description | String | True | A description of the equipment. |
equipmentClassId | String (ULID) | False | The ULID of the equipment class this equipment belongs to. |
locationId | String (ULID) | True | The ULID of the location where this equipment is stationed. |
path | String | True | The path of the equipment. |
id | String (ULID) | True | The ULID of the equipment. Used when updating. |
notes | String | True | Notes related to the equipment. |
enabled | Boolean | True | Indicates if the equipment is active. Default value is true. |
spare1 | String | True | Additional field for user-defined context. |
spare2 | String | True | Additional field for user-defined context. |
spare3 | String | True | Additional field for user-defined context. |
Returns
Returns a JSON object where keys are field names and values are lists of validation violation messages.
Code Examples
equipmentData = system.mes.equipment.newEquipment()
equipmentData['name'] = 'Pump-101'
equipmentData['equipmentClassId'] = 'Pumps/CentrifugalPumps'
validationErrors = system.mes.equipment.validateEquipment(**equipmentData)
if len(validationErrors) > 0:
print('Validation errors found:', validationErrors)
else:
print('Equipment parameters are valid.')