Create appointment from Java

Hi,

I’m trying to create an appointment from a remote Java application. I think this should be very easy, but I’m finding it hard going. I have eventually got to the point where I can create the appointment, and I can see it in the Notes calendar, but when I try to open it I get the message:

“Error trying to open document: Note item not found”

The appointment then opens OK, and if I save it again, this document seems to be OK, but obviously I don’t want the error message.

My code looks like this:

Session s = NotesFactory.createSession(“dominovm:63148”, “Trip Tucker/northgate-is”, “trip1234”);

DbDirectory dbDir = s.getDbDirectory(null);

Database db = dbDir.openMailDatabase();

Document doc = db.createDocument();

doc.appendItemValue(“Form”, “Appointment”);

doc.appendItemValue(“Subject”, “Created from Java19”);

doc.appendItemValue(“AppointmentType”, “0”);

doc.appendItemValue(“StartDate”, s.createDateTime(“17/06/2005”));

doc.appendItemValue(“EndDate”, s.createDateTime(“17/06/2005”));

doc.appendItemValue(“StartTime”, s.createDateTime(“09:00:00 AM”));

doc.appendItemValue(“EndTime”, s.createDateTime(“10:00:00 AM”));

doc.appendItemValue(“StartDateTime”, s.createDateTime(new GregorianCalendar(2005, 5, 17, 9, 0)));

doc.appendItemValue(“EndDateTime”, s.createDateTime(new GregorianCalendar(2005, 5, 17, 10, 0)));

doc.appendItemValue(“CalendarDateTime”, s.createDateTime(new GregorianCalendar(2005, 5, 17, 9, 0)));

doc.replaceItemValue(“$MessageType”, “Not a Draft”);

doc.replaceItemValue(“$PublicAccess”, “1”);

doc.replaceItemValue(“_ViewIcon”, new Integer(160));

doc.save(true, true);

(This is pretty much based on other code I have found lurking in the forums.)

I guess I must be missing an item or two to make it work properly, but I haven’t a clue which ones. Could someone please help?!

Thanks,

Phil

Subject: Create appointment from Java

There are other fields you need to include such as:$CSVersion

ApptUNID

AppointmentType

Chair

etc…

You might want to compare an appointment you create in the mail box via a Notes Client with the fields you are trying to set, to see what else you are missing.

Subject: RE: Create appointment from Java

I have had a look at the properties which get created through Notes, and there are quite a lot, and I doubt I have to create them all (nor know how to create them all).

Has anyone got a working example of this? (Please?!)

Subject: Solution

Found some more code in the forums which was doing something similar. By painful deduction I have worked out that to get past the “Note item not found” problem I had, I needed to add the following items to my document:

String username = s.getUserName();

doc.replaceItemValue(“Chair”, username);

doc.replaceItemValue(“Principal”, username);

I found I needed both of these, otherwise the attachments icon didn’t show in the appointment (?!).

I’m probably still missing something which will bite later, but I’ll worry about that then :wink: