Problem creating a Reservation via SSJS in the Rooms and Resources database

I’m trying to use a Server Side JavaScript function to post a reservation into the Rooms and Resources database.

The code I’m using is this :-

doc = db.createDocument(); // db = R&R database

doc.replaceItemValue(“Form”, “Reservation”);

doc.replaceItemValue(“Principal”, session.getEffectiveUserName());

doc.replaceItemValue(“Chair”, session.getEffectiveUserName());

doc.replaceItemValue(“ReservedFor”, session.getEffectiveUserName());

doc.replaceItemValue(“RQStatus”, “T”);

doc.replaceItemValue(“NoticeType”, “I”);

doc.replaceItemValue(“ResourceName”, nameName.getCanonical());

doc.replaceItemValue(“Purpose”, strSubject);

doc.replaceItemValue(“Topic”, strSubject);

doc.replaceItemValue(“CalendarDateTime”, timeStart);

doc.replaceItemValue(“StartDate”, timeStart);

doc.replaceItemValue(“StartTime”, timeStart);

doc.replaceItemValue(“StartDateTime”, timeStart);

doc.replaceItemValue(“EndDate”, timeEnd);

doc.replaceItemValue(“EndTime”, timeEnd);

doc.replaceItemValue(“EndDateTime”, timeEnd);

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

doc.computeWithForm(false, false);

doc.save();

The document is created ok and shows in the views but RnRMgr spits it out with:-

“RnRMgr: Error processing reservation document (UNID blahblah) in database ssresources.nsf”

and the reservation stays ‘Awaiting Approval’.

I’ve tried setting the form to ‘Notice’ and that doesn’t work either, also adding a ‘$BusyName’ doesn’t help.

Can anyone see what I’m missing?

Many thanks to anyone who can help.

Subject: 2 thoughts

#1:My first glance revealed nothing out of the ordinary except you did not put an ApptUNID item on the request. The ApptUNID item is the textified UNID of the Chairs copy of the entry. If you are doing this to “direct book” then simply textify your new requests UNID and save it as the ApptUNID item.

Its not clear if that omission alone would cause the request to just sit there so I put your LotusScript into an Agent, made a couple tweaks and then ran it.

#2:

My request did get autoprocessed but the request failed because the starting / ending values I used were wildcarded (because Im not a great LS programmer…?). I didnt have dates/times from a web service so I simply used @Today and @Tomorrow for them. That meant I didnt have any times on them and when the RnRMgr looked up if the room was available it failed my request with:

RetrieveSchedule> User bkahn/Kahn sent a request interval with a bad/wildcarded Time-Date on it!

You may have a similar problem. On your server do a set config DEBUG_SCHED_ALL=1 and then repeat your calls. You should see the busytime lookup being done by the RnRMgr starting with a line like:

RetrieveSchedule> dwOptions = 0x2, pDetails=No, piCalList=No

and then see if any errors were passed back.

#2.5:

For that matter you should also check the $CSTrack of your requests and see if they are getting processed or not. RnRMgr should be putting any errors it gets into the $CSTrack item. You can also set CSLogAutoprocess=1 on the server before you run a test and then look at that output to see if it reports a problem or if it shows the request being processed (and failing or not)

Bruce

IBM

Subject: Strange error from resource

I’m having the same issue and tried your debugging settings and it showed me this error: 23-09-2010 21:43:37 Autoprocess: Message 0022BB95 for ‘Ny Opel Zafira/Vognpark/XXX’: Processing reservation mode=0 conflict=0 flags=0x10

23-09-2010 21:43:37 Autoprocess: Message 0022BB95 for ‘Ny Opel Zafira/Vognpark/XXX’: Error You do not have a mail file/server specified. Use File Locations Manage Locations… to set them. (0xE0C) processing – Do NOT keep

23-09-2010 21:43:37 RnRMgr: Error processing reservation document (NoteID: NT00000BA2) in database resource.nsf

Can you explain what this means. I checked the resource and site documents and they seem fine but something might be missing. I don’t know the inner workings of the resource database.

Best regards

Klaus Terman

Subject: Any results?

Just checking to see if you have some results or further data on the problem (or you solved it).

Bruce

IBM

Subject: Think it was the apptUNID field

Here’s the set of fields that works:-

		var docRoomBooking:NotesDocument = dbRooms.createDocument();

		docRoomBooking.replaceItemValue("Form", "Reservation");

		docRoomBooking.replaceItemValue("Principal", strName);

		docRoomBooking.replaceItemValue("From", strName);

		docRoomBooking.replaceItemValue("Chair", strName);

		docRoomBooking.replaceItemValue("RQStatus", "T");

		docRoomBooking.replaceItemValue("NoticeType", "I");

		docRoomBooking.replaceItemValue("$BusyName", nameRoom.getCanonical());

		docRoomBooking.replaceItemValue("ApptUNID", docCalendar.getUniversalID());

		docRoomBooking.replaceItemValue("ResourceName", nameRoom.getCanonical());

		docRoomBooking.replaceItemValue("$BusyPriority", "1");

		docRoomBooking.replaceItemValue("StartDate", timeStart);

		docRoomBooking.replaceItemValue("StartDateTime", timeStart);

		docRoomBooking.replaceItemValue("StartTime", timeStart);

		docRoomBooking.replaceItemValue("EndDate", timeEnd);

		docRoomBooking.replaceItemValue("EndDateTime", timeEnd);

		docRoomBooking.replaceItemValue("EndTime", timeEnd);

		docRoomBooking.replaceItemValue("Topic", strSubject);

		docRoomBooking.computeWithForm(false, false);

		docRoomBooking.save();

So I think it was the apptUNID field that was causing the problem.

Subject: Adjust that a little please

You should not include:

		docRoomBooking.replaceItemValue("$BusyName", nameRoom.getCanonical());

in your code. The $BusyName is ONLY meant to be on ‘booked’ entries in the R&R dB. It should not appear on pending requests that RnRMgr has yet to process.

In the past (pre-R7) this was ok to do because of how the R&R system operated but with the advent of the RnRMgr this is no longer necessary and could cause some unexpected (but not fatally bad) behavior.

You should include whom the request is for and who sent it by including:

		docRoomBooking.replaceItemValue("ReservedBy", strName);

		docRoomBooking.replaceItemValue("ReservedFor", strName);

in case the prominence of those items ever change.

Bruce

IBM