0
votes

I got a panel which bind to an open document as data source called document1 in an extlib dialog box. On button save, I want to compare all the field values between back-end document and document1. However, all the field values from back-end document are seemed to be updated therefore their field values are the same in document1. The comparison is done before docuemnt1.save().

From my understanding, document1.getDocument() should get the back-end document which all original/current data. document1.getDocument(true) should get all new data. I had try to getDocumentByID and found that all field values are updated in back-end document. I have no idea because document1.save not yet executed.

Why back-end document being updated with new data before save?

Is there any better way to get back-end document which all original/current data?

1

1 Answers

2
votes

If you are using the the parameter true with the getDocument method, all changes done to the datasource are temporarly written to the datasoure's datastore.

The XPages engine is "smart enough" to realize that multiple instances of a NotesDocument object are all referencing the same backend document. It will now return the cached data from the datasource's datastore. That is why all objects will now return the updated values instead of the values stored in the backend document (Using of multiple datasources will give you the same result).

To access the data from the backend document, you can use a @DbLookup on a view with all documents sorted by their UNID.

@DbLookup("","AllByUNID", document1.getDocument( true ).getUniversalID(), "FIELD")