According to a parameter date, can we obtain all users with a schedule including this date ???
You can, but it would be a really ugly amount of scripting. It wouldn’t be a bad idea if we made this a little easier for you – let me think a bit about what would benefit the most users and I’ll make a ticket. This should be pretty easy for us to do.
Yes indeed, the goal is to detect (and display) users will be notified by the alarm notification module according to their schedule.
Any help will be welcome !
Luckily for you I have some new people that needed to learn how to add scripting functions, and this one was easily enough that it made a good teaching tool.
Look for system.user.isUserScheduled() and system.user.getScheduledUsers() in 7.9.7
Cool, hope this new release will be ready for this Christmas
The beta should be out before then. Code freeze is on Nov 24 for 7.9.7.
Version 7.9.6 will be released in th meantime ??? or user.isUserScheduled() and system.user.getScheduledUsers() will be added in 7.9.6 ?
7.9.6 should come out very soon. It was sent to QA at the end of October, and the last I heard testing was going well.
Terrific all these news release in this short time
I was looking at the same issue today. With some help from the Javadocs, I pieced together how to extract schedule times from the schedules.
Basically, once you get a schedule, you can call ‘getScheduleForDay(java.util.Calendar.getInstance())’ to get a days schedule in the form of a ‘Timeline’ object. Then you pull TimeSegments out of it for the current day.
The code below then pulls java.util.Date values from the segments. Note that there appears to be some mixup in the toString method for the Timeline that shows time segments in EST but with an offset as if they were UTC…I think, lol.
Anyway, here’s some code that you can put into the Script Console if you’re interested to extract the start and end time of a given segment. Then, of course you could iterate through the schedules and segments for a day and compare against the current time. There appear to be some helper methods in the Timelines that may make it a bit simpler, but none of it is well documented and I haven’t tried it.
Anyway, the code:
import datetime import java.util # Reference current time from datetime lib 'Today: ' + str(datetime.datetime.now()) # Get List of schedules and pick one schedules = system.user.getSchedules() aSchedule = schedules 'Schedule Name: ' + aSchedule.getName() # Get a Calendar instance represnting now tod = java.util.Calendar.getInstance() # Get Timeline from schedule for today timeline = aSchedule.getScheduleForDay(tod) 'Timeline: ' + str(timeline) # Get Time Seqments for Today timelineSegments = timeline.getSegments() 'Segments: ' + str(timelineSegments) # Grab first segment and get start and end time. starting = timelineSegments.getStart() ending = timelineSegments.getEnd() 'First Segment Start: Long Value -- ' + str(starting) 'Schedule Type: ' + str(aSchedule.getType()) 'Schedule Saturday Time Definition: ' + str(aSchedule.getSaturdayTime()) # Use Style object to extract Date values for timeline start and end long values style = timeline.getStyle() 'Timeline Style: ' + str(style) style.toDateForStyle(sta) style.toDateForStyle(ending)
Just as a note for future readers, getScheduleForDay() can return null if there’s no schedule for that day. Also it doesn’t take into account schedule adjustments (and it may not take holidays into account – can’t remember at the moment.)