readRange (NotesCalendar - JavaScript)

Gets a summary of calendar entries for a range of times.

Defined in

NotesCalendar

Syntax

readRange(start:NotesDateTime, end:NotesDateTime) : string

readRange(start:NotesDateTime, end:NotesDateTime, skipcount:int, maxread:int) : string

Parameter Description
start The start time of the range.
end The end time of the range. An exception occurs if the end time is not greater than the start time.
skipcount The number of entries to skip from the beginning of the range. This parameter can be used in conjunction with EntriesProcessed to read the entries in a series of calls.
maxread The maximum number of entries to read.
Return value Description
string A summary in iCalendar format of the entries from the start date to the end date, inclusive. An exception occurs if the range contains no entries.

Usage

For recurring entries, each entry in the range appears as a separate VEVENT with a unique recurrence ID.

Each entry contains a UID item whose value can be used to get the corresponding NotesCalendarEntry object.

Inclusion in a date range is determined by the start time of a meeting.

The content of the return value is modified by any values set for ReadRangeMask1 and ReadRangeMask2.

Use the last two parameters in conjunction with EntriesProcessed to process entries in successive operations. See EntriesProcessed for an example using the last two parameters.

Examples

This button event gets calendar and scheduling information for the current user for today and tomorrow.
// Get calendar for current user
var dbdir:NotesDbDirectory = session.getDbDirectory("");
var maildb:NotesDatabase = dbdir.openMailDatabase();
var cal:NotesCalendar = session.getCalendar(maildb);
var dt1:NotesDateTime = session.createDateTime("Today 08");
var dt2:NotesDateTime = session.createDateTime("Tomorrow 17");
// Read range and set to requestScope variable bound to multiline text box
try {
	requestScope.status = cal.readRange(dt1, dt2);
} catch(e) {
	requestScope.status = "Nothing in that range";
}
This is sample output.
BEGIN:VCALENDAR
X-LOTUS-CHARSET:UTF-8
VERSION:2.0
BEGIN:VEVENT
DTSTART:20120403T183000Z
DTEND:20120403T190000Z
TRANSP:OPAQUE
RECURRENCE-ID:20120403T183000Z
DTSTAMP:20120403T141313Z
SEQUENCE:3
X-LOTUS-ORGANIZER:CN=Robert F Harwood/OU=Westford/O=IBM
CLASS:PUBLIC
SUMMARY:Domino Designer ID Team meeting
UID:F0A3694E4E7E20938525790F004D370A-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-NOTICETYPE:A
X-LOTUS-APPTTYPE:3
END:VEVENT
BEGIN:VEVENT
DTSTART:20120403T190000Z
DTEND:20120403T200000Z
TRANSP:OPAQUE
DTSTAMP:20120403T141313Z
SEQUENCE:0
X-LOTUS-ORGANIZER:CN=Craig Lordan/OU=Westford/O=IBM
X-LOTUS-ROOM:B2-B2104/LKG2/550 King St/MA-Littleton@IBMUS
CLASS:PUBLIC
SUMMARY:Translation packaging enablement session by Bruce Webster
LOCATION:USA: 888-555-5555 | passcode: 5555555
UID:C4FC689987507AC2852579CF00720024-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-NOTICETYPE:A
X-LOTUS-APPTTYPE:3
X-LOTUS-ONLINEMEETING-URL:http://www.webdialogs.com/
X-LOTUS-ONLINEMEETING-CONFID:w555
END:VEVENT
BEGIN:VEVENT
DTSTART:20120404T124500Z
DTEND:20120404T131500Z
TRANSP:OPAQUE
RECURRENCE-ID:20120404T124500Z
DTSTAMP:20120403T141313Z
SEQUENCE:0
X-LOTUS-ORGANIZER:CN=Maire Kehoe/OU=Ireland/O=IBM
X-LOTUS-ROOM:G07 - Meeting Room/Campus Building 6@IBMIE
CLASS:PUBLIC
SUMMARY:XPages scrum
LOCATION:Location: \nIRELAND Toll-Free
 :  1-800-555-555\nIRELAND Caller Paid
 :  0-1-5555555\nUSA Caller Paid 555-555-5555\nUSA Toll-Free 888-555-55
 55\nUnited Kingdom Caller Paid 0-55-55555555\nUnited Kingdom Toll-Free
  0800-555-5555\nParticipant Code:  5555555\nFor other Countries
 : \nhttps
 ://www.teleconference.att.com/servlet/glbAccess?process=1&accessCode=5
 555555&accessNumber=015555555
UID:26CBC9B27E8660C1802579B3003DF9C0-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-NOTICETYPE:A
X-LOTUS-APPTTYPE:3
END:VEVENT
END:VCALENDAR
This button event parses calendar and scheduling information for the current user for today and tomorrow, returning the start time, summary, and identifier for each entry.
var dbdir:NotesDbDirectory = session.getDbDirectory("mymailserver");
var maildb:NotesDatabase = dbdir.openMailDatabase();
var cal:NotesCalendar = session.getCalendar(maildb);
var dt1:NotesDateTime = session.createDateTime("Today 08");
var dt2:NotesDateTime = session.createDateTime("Tomorrow 17");
try {

var calrange:string = cal.readRange(dt1, dt2);
var p1 = calrange.indexOf("DTSTART:");
while (p1 != -1) {
	p1 = p1 + 8;
	var p2 = calrange.indexOf("\n", p1) - 1;
	var dtstart:string = calrange.substr(p1, p2 - p1);
	requestScope.status = requestScope.status + dtstart + "\n";
	p1 = calrange.indexOf("SUMMARY:", p2) + 8;
	p2 = calrange.indexOf("\n", p1) - 1;
	var summary:string = calrange.substr(p1, p2 - p1);
	requestScope.status = requestScope.status + summary + "\n";
	p1 = calrange.indexOf("UID:", p2) + 4;
	p2 = calrange.indexOf("\n", p1) - 1;
	var uid:sting = calrange.substr(p1, p2 - p1);
	requestScope.status = requestScope.status + uid + "\n\n";
	p1 = calrange.indexOf("DTSTART:", p2);
}

} catch(e) {
	requestScope.status = "Nothing in that range";
}

LotusScript® examples

This agent gets calendar and scheduling information for the current user for today and tomorrow.
Sub Initialize
	Dim session As New NotesSession
	Dim maildb As New NotesDatabase("", "")
	Dim cal As NotesCalendar
	Dim dt1 As NotesDateTime
	Dim dt2 As notesdatetime
	Dim db As NotesDatabase
	Dim doc As NotesDocument
	Dim body As NotesRichTextItem
	REM Get calendar for current user
	Call maildb.Openmail()
	Set cal = session.getCalendar(maildb) ' Not In ref pane
	Set dt1 = session.createdatetime("Today 08")
	Set dt2 = session.Createdatetime("Tomorrow 17")
	Set db = session.CurrentDatabase
	REM Create document to post results
	Set doc = db.CreateDocument
	doc.Form = "main"
	doc.Subject = "Today 08"
	Set body = doc.Createrichtextitem("body")
	REM Read range and put in body of document
	Call body.Appendtext(cal.ReadRange(dt1, dt2))
	Call doc.Save( True, True )
End Sub

Java examples

This agent gets calendar and scheduling information for the current user for today and tomorrow.
import lotus.domino.*;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();

          // (Your code goes here)
          // Get calendar for current user
          DbDirectory dbdir = session.getDbDirectory("");
          Database maildb = dbdir.openMailDatabase();
          NotesCalendar cal = session.getCalendar(maildb);
          DateTime dt1 = session.createDateTime("Today 08");
          DateTime dt2 = session.createDateTime("Tomorrow 17");
          // Create document to post results
          Database db = agentContext.getCurrentDatabase();
          Document doc = db.createDocument();
          doc.appendItemValue("Form", "main");
          doc.appendItemValue("subject", "Today 08");
          RichTextItem body = doc.createRichTextItem("body");
          // Read range and put in body of document
          body.appendText(cal.readRange(dt1, dt2));
          doc.save(true, true);

      } catch(Exception e) {
          e.printStackTrace();
       }
   }
}