Boy am I sick of xpages documentation

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:

<xp:button value=“Create response document” id=“button2”

style=“width:141.0px”><xp:eventHandler event=“onclick” submit=“true” refreshMode=“complete”>

xp:this.action

<xp:createResponse name="/x1.xsp"

	parentId="#{javascript:requestScope.unid}">

</xp:createResponse>

</xp:this.action></xp:eventHandler></xp:button>

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.

Subject: Have you tried SSJS

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.

For a complete copy:

var inheritDoc = database.createDocument();

inheritDoc.appendItemValue(“Form”,“FORM_NAME”);

testDoc.getDocument().copyAllItems(inheritDoc,false);

inheritDoc.save();

Getting select fields (again if they’re not in the requestScope):

var inheritDoc = database.createDocument();

inheritDoc.appendItemValue(“Form”,“FORM_NAME”);

inheritDoc.appendItemValue(“Field_NAME”,testDoc.getDocument().getItemValueString(“FIELD_NAME”));

inheritDoc.save();

Subject: Wow! Finally! One More Question, please?

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 :slight_smile:

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?

Many thanks again!

Subject: to get the rti field in xpages

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();

}

catch (err) {

// note: didnt add attributes to err

inheritDoc.appendItemValue("field1","Error");

inheritDoc.save();

}

Subject: Thanks!

As they say in French…ca marche!

Many thanks (and happy new year!)

Subject: A Link

Sorry, I can’t help with your issue, however I can point you to XPage.info:

http://xpages.info/XPagesHome.nsf/Home.xsp

which may provide some assistance. You may be able to connect with someone there can answer your question.

HTH.

Gregg