Hello again, everyone.
I’d love to use the built-in Schedule Management component instead of developing my own, but our customer wants the schedules to be in a monthly display. So, my plan was to have them make the schedules in the schedule management component and then have a display using the Month View component and bind the schedule as the calendar events.
Unfortunately, I have yet to find a way to extract the daily schedule from the management component. I’ve seen the scripts getSchedules and getUserSchedules (or something like that), and unless I’m missing something, I don’t think those will work.
Has anyone ran into this problem before?
Any help is appreciated.
TIA
You could use system.user.getSchedule(“ScheduleAAA”) and loop through a month calling getScheduleForDay().
The date <-> cal conversions need to be fixed to handle events that span midnight… but this might get you started:
from java.util import Calendar
cal = Calendar.getInstance()
cal.set(Calendar.DAY_OF_MONTH, 1)
days = cal.getActualMaximum(Calendar.DAY_OF_MONTH)
sched = system.user.getSchedule("AAAAAAA")
headers = ["startDate","endDate","displayColor","display"]
rows = []
for x in range(days):
day = sched.getScheduleForDay(cal)
if day:
for ev in day.getSegments():
cal.set(Calendar.HOUR_OF_DAY, 0)
cal.set(Calendar.MINUTE, 0)
cal.set(Calendar.SECOND, 0)
cal.set(Calendar.MILLISECOND, 0)
row = []
cal.add(Calendar.MILLISECOND, ev.getStart())
start = cal.getTime()
cal.add(Calendar.MILLISECOND, ev.getEnd())
end = cal.getTime()
row.append(start)
row.append(end)
row.append("blue")
row.append("<html>%s -> %s" % (start, end))
rows.append(row)
cal.add(Calendar.DAY_OF_MONTH, 1)
ds = system.dataset.toDataSet(headers, rows)
event.source.parent.getComponent('Month View').events = ds
thanks I’ll give this a shot Monday and update this topic