Thanks for the responses Bill and David, I've seen your other "do not use" response documents comments throughout the forum while I was trying to research this issue. Yes the app is hybrid - XPages for external and internal use the traditional notes elements. Unfortunately not all apps can be built from green fields so using response documents and maintaining this database's current structure is required to remain within the client's budget/time frame and their staff's current processes and familiarity.
BUT the issue is repeatable outside of the use of response documents anyway. Taking the evil 'response' wording out of this for a moment, the problem is that I have is that when a copyAllItems is used to build a new document data source for a page, when unsaved and presented into an XPage bound to a computed field control, on the data source save via a button on the xpage, it removes the entire field in the data source document.
Here is a stripped down page to demonstrate the issue. You'll need to create a form called "testform" with fields "field1" & "field2". Note that when you open the page, the computed field control binded to document1.field2 shows the value but when you click save, the value disappears - because the field doesn't exist on document1 anymore. As I mentioned in the first post, using an Edit Box with read only etc doesn't resolve the issue either.
Sample page that will cause the issue.
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.data>
<xp:dominoDocument var="document1" formName="testform"></xp:dominoDocument>
</xp:this.data>
<xp:this.beforePageLoad><![CDATA[#{javascript:var getDoc = database.getDocumentByUNID("1157F42AE5A17FFA4A257F02007B769F") //Change to UNID within your database
if (getDoc){
getDoc.copyAllItems(document1.getDocument(), false);
}
}]]></xp:this.beforePageLoad>
<xp:inputText id="inputText1" value="#{document1.field1}"></xp:inputText>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:text escape="true" id="computedField1" value="#{document1.field2}"></xp:text>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:button value="Save" id="button1"><xp:eventHandler event="onclick" submit="true" refreshMode="complete">
<xp:this.action>
<xp:saveDocument var="document1"></xp:saveDocument>
</xp:this.action></xp:eventHandler></xp:button></xp:view>
Workarounds:
1) Saving document1 after the copyAllItems will eliminate the issue, however this will cause rogue documents in the database if the user cancels (user doesn't have deletion access and no scheduled agents to delete these docs either please)
2) Binding an Edit Box with display:none to document1.field2 on the xpage in addition to the Computed Field binded to the same will also resolve the issue - credit to David for this (see link in first post) but the difference here is that I'm not trying to update the computed field on the fly. Unfortunately I'll have to do this about 45 times on the page (so 45 extra controls = messy). Probably the way I'll need to go though.
I'm thinking that this will fall into the "it can't be done" category, but really it's pretty basic what I'm trying to do so it's a shame that XPages does this.