Skip to main content

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

- assetIdIntegerId of the asset associated with the schedule block
- assetPathString
- colorStringColor code for the schedule block
- endStringString format of the endDate
- endDateDateTimeEnd date of the schedule block
- itemIdIntegerId of the item associated with the schedule block or None
- modeIdIntegerId of the mode associated with the schedule block
- notesStringAdditional notes for the schedule block
- rruleStrStringRecurrence rule string (e.g., 'FREQ=DAILY;INTERVAL=1')
- scheduleBlockIdIntegerNone for a new block
- scheduleBlockNameStringName of the schedule block
- scheduledQtyFloatQuantity to be scheduled
- startStringString format of the startDate
- startDateDateTimeStart date of the schedule block
- timezoneString
- workOrderIdIntegerId of the work order associated with the schedule block or None

**** ``
scheduleConfig Dictionary

- intelligentSchedulingBooleanWhen enabled, we will check if the event overlaps with existing events
- shiftTimeOnlyBooleanIf 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)