# 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`<br />
<table class='dictionaryKeyTable'>
	<tbody>
 	<tr><td> - assetId</td><td>Integer</td><td>Id of the asset associated with the schedule block</td></tr>	
 	<tr><td> - assetPath</td><td>String</td><td></td></tr>	
 	<tr><td> - color</td><td>String</td><td>Color code for the schedule block</td></tr>	
 	<tr><td> - end</td><td>String</td><td>String format of the endDate</td></tr>	
 	<tr><td> - endDate</td><td>DateTime</td><td>End date of the schedule block</td></tr>	
 	<tr><td> - itemId</td><td>Integer</td><td>Id of the item associated with the schedule block or None</td></tr>	
 	<tr><td> - modeId</td><td>Integer</td><td>Id of the mode associated with the schedule block</td></tr>	
 	<tr><td> - notes</td><td>String</td><td>Additional notes for the schedule block</td></tr>	
 	<tr><td> - rruleStr</td><td>String</td><td>Recurrence rule string (e.g., 'FREQ=DAILY;INTERVAL=1')</td></tr>	
 	<tr><td> - scheduleBlockId</td><td>Integer</td><td>None for a new block</td></tr>	
 	<tr><td> - scheduleBlockName</td><td>String</td><td>Name of the schedule block</td></tr>	
 	<tr><td> - scheduledQty</td><td>Float</td><td>Quantity to be scheduled</td></tr>	
 	<tr><td> - start</td><td>String</td><td>String format of the startDate</td></tr>	
 	<tr><td> - startDate</td><td>DateTime</td><td>Start date of the schedule block</td></tr>	
 	<tr><td> - timezone</td><td>String</td><td></td></tr>	
 	<tr><td> - workOrderId</td><td>Integer</td><td>Id of the work order associated with the schedule block or None</td></tr>	
	</tbody>
</table>

**** ``<br />
**scheduleConfig** `Dictionary`<br />
<table class='dictionaryKeyTable'>
	<tbody>
 	<tr><td> - intelligentScheduling</td><td>Boolean</td><td>When enabled, we will check if the event overlaps with existing events</td></tr>	
 	<tr><td> - shiftTimeOnly</td><td>Boolean</td><td>If True, event times will be adjusted to schedule during shift times</td></tr>	
	</tbody>
</table>

**scheduleOption** `String`: i.e. 'default'- does not affect existing events, 'fixed' - modifies overlapping events, 'override' - deletes overlapping events, 'wrap' - wraps around existing events<br />
**userId** `Integer`:Id of the user executing the function<br />

---
### Example
```python
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)
```
