Search code examples
xpageslotus-notescomputed-field

Forcing Computed Fields on a Document to Recalculate using SSJS


Is there a way to force a documents computed fields to recalculate from within an Xpage, without saving the document?

I have a subform on a Notes database with many computed fields, these contain some complex calculations involving time range calculations. The database is used as both a web and client application. For the custom control containing the fields I don't want to have to recreate all the calculations, so have a computed text value bound to the computed form on the document.

On the subform as you tab through entering the information the computed fields are recalculated. On the custom control I have a refresh button which saves the datasource and does a partial refresh of the data entry section, but this can cause some errors or document save conflicts.

I will recreate the calculations if need be, but I just wondered if there is a slicker way of achieving this before I start that process?


Solution

  • DominoDocumentData object has computeDocument() and doComputeDocument() methods. I'm not sure what they do. If you look at the class for your XPage / Custom Control under Local\xsp you can see them. Using the variable name for your datasource, e.g. document1, you will be able to get a hold of the DominoDocumentData object and case it to that class.