system.kanoa.schedule.scheduleOperation(scheduleBlockInfo, scheduleConfig, scheduleOption, userId)
Schedules an operation that flexibly adheres to the asset's shift schedule and schedule config settings, while also avoiding any currently existing schedule blocks.
Parameters
scheduleBlockInfo Dictionary
| - assetId | Integer | Id of the asset associated with the schedule block |
| - assetPath | String | |
| - color | String | Color code for the schedule block |
| - end | String | String format of the endDate |
| - endDate | DateTime | End date of the schedule block |
| - itemId | Integer | Id of the item associated with the schedule block or None |
| - modeId | Integer | Id of the mode associated with the schedule block |
| - notes | String | Additional notes for the schedule block |
| - rruleStr | String | Recurrence rule string (e.g., 'FREQ=DAILY;INTERVAL=1') |
| - scheduleBlockId | Integer | None for a new block |
| - scheduleBlockName | String | Name of the schedule block |
| - scheduledQty | Float | Quantity to be scheduled |
| - start | String | String format of the startDate |
| - startDate | DateTime | Start date of the schedule block |
| - timezone | String | |
| - workOrderId | Integer | Id of the work order associated with the schedule block or None |
**** ``
scheduleConfig Dictionary
| - intelligentScheduling | Boolean | When enabled, we will check if the event overlaps with existing events |
| - shiftTimeOnly | Boolean | If True, event times will be adjusted to schedule during shift times |
scheduleOption String: i.e. 'default'- does not affect existing events, 'fixed' - modifies overlapping events, 'override' - deletes overlapping events, 'wrap' - wraps around existing events
userId Integer:Id of the user executing the function
Example
assetId = 901
assetInfo = system.kanoa.utilities.convertDatasetRowToJSON(system.kanoa.asset.getAssets({'assetId': assetId}), 0)
start = "2026-07-28 12:00:00"
end = "2026-07-28 15:00:00"
scheduleBlockinfo = {
'scheduleBlockId': None,
'scheduleBlockName': 'Maintenance',
'assetId': assetId,
'assetPath': assetInfo['assetPath'],
'timezone': assetInfo['timeZone'],
'itemId': None,
'workOrderId': None,
'scheduledQty': None,
'modeId': 3,
'start': start,
'end': end,
'startDate': system.date.parse(start),
'endDate': system.date.parse(end),
'notes': 'Maintenance notes',
'rruleStr': 'FREQ=DAILY;INTERVAL=1',
'color': '#FF0000'
}
userId = system.kanoa.security.getIDPUserId({'userName': 'SYSTEM'})
scheduleConfig = {'shiftTimeOnly': True, 'intelligentScheduling': True}
scheduleOption = 'default'
addedScheduleBlockIds, msg = system.kanoa.schedule.scheduleOperation(scheduleBlockinfo, scheduleConfig, scheduleOption, userId)