So…what I’m trying to do is to create a new document from an existing one in xPages, populated with only specific fields from the old doc. I figured I’d create a response doc then delete the $Ref from the new doc so it wasn’t a response doc anymore…pretty straightforward Notes.
xPages documentation said to use this code to create the response doc:
Literally my only change was to change the x1.xsp to my new xpages form control name.
which geneated this error:
com.ibm.xsp.model.domino.wrapped.DominoDocument incompatible with lotus.domino.Document
What a bunch of junk. I am so sick of the money and time we’ve wasted on this half documented, half arsed xPages product I could scream. No wonder SharePoint is doing so well. This product shouldn’t have ever been released.
Now that I have that off my back, anyone have any ideas? The simple action to create a response document doesn’t work. I get an error that a parent document must be available (this after searching half an hour to find out what to put in the Parent Doc ID (duh, if it’s a response doc why do you need to ask…it’s the parentdoc.unid, stupid).
Again, just trying to create a new document based on an old one and inherit some fields off the old document.
Did you try writing a solution in pure SSJS? I say this knowing little about your environment (I don’t know that requestScope is holding a unid variable for example). That said try attaching something below to a button.
Thank you so much! Two days of frustration solved!
I have rich text fields, so had to modify your AppendItemValue as it doesn’t work on the rich text stuff. Since I only copy selected fields from the old doc to the new one, I attempted to modify your code to use the copyItem param instead of CopyAllItems. It totally failed, stating there was no copyItem property. But removeItem does work. so I work backwards and remove what’s not needed
But how do I change perspective to the new document from within the button? I’d like to change perspective to the new doc so I can edit it prior to saving. Does this involve getting the UNID of the new document at some point?
Sorry for the delayed response - the Holidays. Hopefully this is helpful. Below is a way to get the RTI information of the current document and place it into the inherited document. I wrapped it in a try-catch statement, so if it fails to copy the RTI you get an ‘error’ document – obviously just cut that part out if you don’t need it.
var inheritDoc = database.createDocument();
inheritDoc.appendItemValue(“Form”,“test”);
try {
var rti = testDoc.getDocument().getMIMEEntity("Body");
var stream = session.createStream();
stream.writeText(rti.getContentAsText());
var entity = inheritDoc.createMIMEEntity("Body")
entity.setContentFromText(stream,"text/html;charset=UTF-8", 1725);
stream.close();
inheritDoc.save();