Search code examples
xpagesssjs

NotesCalendarEntry with recurring event


Hello I need to solve my old question XPages search calendar range datetime So I have rewrite my code for use NotesCalendar class and now this code return correctly the events (include the recurring/repeat event)

var startDateTime:NotesDateTime = session.createDateTime(new Date(2016,0,1));
var endDateTime:NotesDateTime = session.createDateTime(new Date(2016,1,1));
var cal:NotesCalendar = session.getCalendar(mailDB);
cal.readRange(startDateTime,endDateTime) //work correctly and return VCAL

but I need to read every Calendar Entries for create my JSON object so I have add this code:

var vect:java.util.Vector=cal.getEntries(startDateTime,endDateTime)
 for(j=0;j<vect.size();j++){
       var cale:NotesCalendarEntry = vect.elementAt(j);
        cale.read(); //this return NULL in recurring Event and work in other case   
       cale.recycle();
    }

This is my VCAL generate from cal.readRange(startDateTime,endDateTime)

BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
DTSTART:20160131T080000Z
TRANSP:TRANSPARENT
RECURRENCE-ID:20160131T080000Z
DTSTAMP:20160203T084615Z
CLASS:PRIVATE
SUMMARY:test repeat event
UID:134A501D66B80411C1257E520058802B-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-APPTTYPE:4
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT1H
DESCRIPTION:test repeat event
END:VALARM
END:VEVENT
BEGIN:VEVENT
DTSTART:20160131T090000Z
DTEND:20160131T100000Z
TRANSP:OPAQUE
DTSTAMP:20160203T084615Z
SEQUENCE:0
CLASS:PRIVATE
SUMMARY:private test public appointment
UID:4C5E7D5116C19E7EC1257F4E00301400-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-APPTTYPE:0
END:VEVENT
BEGIN:VEVENT
DTSTART:20160201T070000Z
DTEND:20160201T080000Z
TRANSP:OPAQUE
DTSTAMP:20160203T084615Z
SEQUENCE:0
CLASS:PUBLIC
SUMMARY:public test -appointment
UID:802CB03D0FE29EC7C1257F4C005B9344-Lotus_Notes_Generated
X-LOTUS-SUMMARYDATAONLY:TRUE
X-LOTUS-APPTTYPE:0
END:VEVENT
END:VCALENDAR

If I need to read every recurring events, I think that I need to use the function cale.read("20160131T080000Z") passing the RECURRENCE-ID.

But how can I in NotesCalendarEntry get this parameter my FOR statment?

Thank a lot

P.S. I can use Ical4j Java library I know. is this only solution?


Solution

  • Hello I have solve my problem. I have found a JavaScript library that convert VCAL into JSON object. I have convert this JavaScript client library in SSJS code and voila! Now work perfect and in simple mode!