system.mes.productionOrder.newBillOfMaterialsItem
Generates an empty non-persisted Production Order Bill of Materials object to provide the structure required by the API to save a new record into the database. This method must be combined with the saveBillOfMaterials method in order to persist the record.
Syntax
system.mes.productionOrder.newBillOfMaterialsItem()
Parameters
| Parameter | Type | Nullable | Description |
|---|---|---|---|
| None | - | - | This method does not take any parameters. |
Returns
Returns a JSON representation of the newly created bill of materials object. The following is a list of keys and default values:
| Key | Default Value |
|---|---|
productId | null |
productionOrderId | null |
materialName | null |
materialId | null |
quantityPerProducedUnit | null |
quantityOrder | null |
unitOfMeasureId | null |
unitOfMeasureName | null |
position | 0 |
materialGroup | null |
materialType | PRODUCT |
id | null |
notes | null |
enabled | true |
spare1 | null |
spare2 | null |
spare3 | null |
Code Examples
# Generate the object structure for a new bill of materials object with no initial arguments
newBillOfMaterials = system.mes.productionOrder.newBillOfMaterialsItem()
# Set basic attributes for the new bill of materials
newBillOfMaterials['quantityOrder'] = 1000.0
newBillOfMaterials['materialGroup'] = 'CAN'
newBillOfMaterials['unitOfMeasureId'] = '01JCH3EPVP-1MNNDJTS-37Z75NGB'
newBillOfMaterials['materialId'] = '01JCH3ENGW-82KJDZDR-JHGYCXQN'
newBillOfMaterials['quantityPerProducedUnit'] = 10.0
# (You can continue setting other properties as needed here)
# Save the new bill of materials to the system
savedBillOfMaterials = system.mes.productionOrder.saveBillOfMaterialsItem(**newBillOfMaterials)
# Output the JSON representation of the saved bill of materials
print(savedBillOfMaterials)