system.kanoa.cmms.addWorkOrderScheduleEvent(workOrderEventInfo, userId)
Adds the maintenance work order (MWO) that a work order schedule or condition generates. Use it from a custom generation job instead of waiting for the automatic generation to run.
The MWO is named by the next serial number of the work order's maintenance type.
If an MWO of the same work order is still open, this one is still added, but as Missed, with a note on its status change naming the open one.
Then the schedule or condition that generated it is stamped with the due date.
To add an MWO with a name and status of your own, use addWorkOrderEvent instead.
Parameters
workOrderEventInfo Dictionary
| - workOrderId | Integer | Required. Id of the work order template |
| - workOrderPriorityId | Integer | Required. Id of the priority, from getWorkOrderPriorities |
| - requestedBy | Integer | Required. Id of the user who requested the work |
| - dueDate | DateTime | Required. When the work is due |
| - assetId | Integer | Optional. Id of the asset the work is done on |
| - assignedTo | Integer | Optional. Id of the user the MWO is assigned to |
| - maintenanceSubTypeId | Integer | Optional. Id of the maintenance sub type, from getMaintenanceSubTypes |
| - workOrderEventStatusId | Integer | Optional. Defaults to Assigned when assignedTo is set, else Open. Missed when an MWO of this work order is still open |
| - workOrderScheduleId | Integer | Optional. Id of the work order schedule that generated the MWO. It's stamped with the dueDate |
| - workOrderConditionId | Integer | Optional. Id of the work order condition that generated the MWO. It's stamped with the dueDate and currentValue |
| - conditionId | Integer | Optional. The older name for workOrderConditionId, read when that isn't given |
| - currentValue | Float | Optional. The condition value that generated the MWO |
userId Integer:Id of the user executing the function
Returns
workOrderEventId Integer None if the MWO wasn't added
message String None if success. When the MWO was added but the schedule or condition couldn't be stamped, both are set
Example
# Add the next seal inspection MWO for Machine 1 from its schedule, due in a week
userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})
workOrders = system.kanoa.cmms.getWorkOrders({'workOrderName': 'Seal Inspection'})
workOrderId = system.kanoa.utilities.getFieldValue('workOrderId', workOrders)
workOrderPriorityId = system.kanoa.utilities.getFieldValue('workOrderPriorityId', workOrders)
workOrderScheduleId = system.kanoa.utilities.getFieldValue('workOrderScheduleId', system.kanoa.cmms.getWorkOrderSchedule({'workOrderId': workOrderId}))
assetId = system.kanoa.utilities.getFieldValue('assetId', system.kanoa.asset.getAssets({'assetPath': 'CoreForge/Philadelphia/Machining/Machine 1'}))
workOrderEventInfo = {
'workOrderId': workOrderId,
'workOrderPriorityId': workOrderPriorityId,
'requestedBy': userId,
'dueDate': system.date.addDays(system.date.now(), 7),
'assetId': assetId,
'workOrderScheduleId': workOrderScheduleId
}
workOrderEventId, message = system.kanoa.cmms.addWorkOrderScheduleEvent(workOrderEventInfo, userId)
print workOrderEventId, message