createReplyMessage with XPages

Hi,

I want to use the createReplyMessage for a document in XPages, but there are now examples in the help file , and hard to figure out how to use. Maybe someone can help me with any hints or code example. This is as far as I’ve got:

Behind my Reply-link I’m setting a couple of sessionScope variables to hold the UNID for the current document with these to JavaScript lines:

sessionScope.currentAction = “Reply”

sessionScope.replyToDocUniversalID = currentDocument.getDocument().getUniversalID();

The link then opens the XPage containing the custom control with a new document. My goal now is to get the document I just closed, use the createReplyMessage method on it, and open the resulting document as source. It is important to avoid saving the document in case the user press cancel or exits the browser.

I have tried this code in beforePageLoad:

if (sessionScope.containsKey(“currentAction”)){

if (sessionScope.get("currentAction").equals("Reply")){

	var thisDatabase = session.getCurrentDatabase();

	replyToDoc:NotesDocument = thisDatabase.getDocumentByUNID(sessionScope.get("replyToDocUniversalID"));

	var newDoc:NotesDocment = replyToDoc.createReplyMessage(true);

}

}

It gives no errors, but I don’t know how to get the newDoc as source for the XPage. I have also tried the same snippet in queryNewDocument, but I have of course the same problem there. I’m using the memoDoc as variable name for the source document in the custom control, an have tried to use that variable name instead of newDoc, but it didn’t work.

Any suggestions are welcome

Subject: Have you considered using the Create Response simple action?

Computing the parent ID as ‘document3.getNoteID()’ which is the id of the current document, the parent document.

Subject: Tried Response Document

Yes, thats a good idea and I’ve tried it.

But with response document I cannot get inheritance of values from the parent doc, even when “On Create: Formulas inherit values from selected document.” are set on the form and default value are set to the name of parent doc’s field.

I could of course use replaceItemValue for each item, but this seems to be a little cumbersome and risky method. Easy to forget some items, and hard to avoid destroying the documents MIME-format.