getAsDocument (NotesCalendarEntry - JavaScript)

Gets the document that contains a calendar entry.

Defined in

NotesCalendarEntry

Syntax

getAsDocument() : void

getAsDocument(flags:int) : void

getAsDocument(flags:int, recurid:string) : void

Parameter Description
flags One of the following:
  • CS_DOCUMENT_NOSPLIT (1)
  • 0
recurid The recurrence identifier (RECURRENCE-ID item) for a recurring calendar event. The format of a recurrence identifier is a time in UTC format, for example, 20120913T160000Z.
Possible exception Value Text Description
NotesError.NOTES_ERR_INVALIDID 4757 Invalid ID The identifier for the NotesCalendarEntry object is not valid.
NotesError.NOTES_ERR_RECURID_NOTFOUND 4808 Recurrence-ID not found The recurrence identifier for the NotesCalendarEntry object is not valid.
NotesError.NOTES_ERR_IDNOTFOUND 4814 Identifier not found The recurrence identifier for the NotesCalendarEntry object does not identify an entry in the calendar, or the scope and recurid are missing for a recurring entry.

Examples

This button event gets a calendar document given its UID.
try {

var dbdir:NotesDbDirectory = session.getDbDirectory("");
var maildb:NotesDatabase = dbdir.openMailDatabase();
var cal:NotesCalendar = session.getCalendar(maildb);
var uid:string = sessionScope.currentuid;
var recurid:string = sessionScope.currentrecurid;
var cale:NotesCalendarEntry = cal.getEntry(uid);
if (recurid == null || recurid == "") {
	var doc:NotesDocument = cale.getAsDocument();
} else {
	var doc:NotesDocument = cale.getAsDocument(NotesCalendarEntry.CS_DOCUMENT_NOSPLIT, recurid);
}
requestScope.status = "Calendar entry for UID " + uid + "\n";
requestScope.status = requestScope.status + doc.getItemValueString("subject");

} catch(e) {
	requestScope.status = e.message;
}

LotusScript® syntax and examples

NotesCalendarEntry.GetAsDocument(Optional flags As Long, Optional Byval recurid As String)
This agent gets a calendar document given its UID.
Sub Initialize
	Dim session As New NotesSession
	Dim maildb As New NotesDatabase("", "")
	Dim cal As NotesCalendar
	Dim cale As NotesCalendarEntry
	Dim uid As String
	Dim caldoc As NotesDocument
	Dim calestr As String
	Dim recurid As String
	Dim db As NotesDatabase
	Dim doc As NotesDocument
	Dim body As NotesRichTextItem
	uid = session.Getenvironmentstring("currentuid")
	If uid = "" Then
		MessageBox "No current UID",, "Error"
		Exit sub
	End If
	recurid = session.Getenvironmentstring("currentrecurid")
	Call maildb.Openmail()
	Set cal = session.getCalendar(maildb)
	Set cale = cal.Getentry(uid)
	If recurid = "" Then
		Set caldoc = cale.Getasdocument()
	Else
		Set caldoc = cale.Getasdocument(0, recurid)
	End If
	calestr = caldoc.Getitemvalue("subject")(0)
	REM Write results to document
	Set db = session.Currentdatabase
	Set doc = db.Createdocument()
	doc.Form = "main"
	doc.Subject = "Calendar entry"
	Set body = doc.Createrichtextitem("body")
	body.Appendtext(calestr)
	Call doc.Save(true, true)
End Sub

Java syntax and examples

void NotesCalendarEntry.getAsDocument()
void NotesCalendarEntry.getAsDocument(int flags)
void NotesCalendarEntry.getAsDocument(int flags, String recurid)
This agent gets a calendar document given its UID.
import lotus.domino.*;

public class JavaAgent extends AgentBase {

    public void NotesMain() {

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

          // (Your code goes here)
          String uid = session.getEnvironmentString("currentuid");
          String calestr = "";
          if (uid != null) {
              DbDirectory dbdir = session.getDbDirectory("");
              Database maildb = dbdir.openMailDatabase();
              NotesCalendar cal = session.getCalendar(maildb);
              NotesCalendarEntry cale = cal.getEntry(uid);
              String recurid = session.getEnvironmentString("currentrecurid");
              Document doc = null;
              if (recurid == null || recurid.length() == 0) {
            	  doc = cale.getAsDocument();
              } else {
            	  doc = cale.getAsDocument(0, recurid);
              }
              calestr = doc.getItemValueString("subject");
          } else {
        	  calestr = "Null UID";
          }
          // Write result to document
          Database db = agentContext.getCurrentDatabase();
          Document doc = db.createDocument();
          doc.appendItemValue("Form", "main");
          doc.appendItemValue("subject", "Calendar entry");
          RichTextItem body = doc.createRichTextItem("body");
          body.appendText(calestr);
          doc.save(true, true);

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