This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jun 1, 2011, 8:08 AM
3 Posts

Forms and computed fields

  • Category: Other
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: forms,computeWithForm
  • Replies: 3
 Hi all
 
I want to know I'm not being stupid and banging my head against a soft foam wall, and if I've missed some prise piece of Wiki knowledge somewhere please point me in the right direction, but... 
 
If I have a document data source defined as
 
<xp:dominoDocument var="userDocument" formName="Person"
computeWithForm="onboth">
<xp:this.postNewDocument><![CDATA[#{javascript:postNewDocument(); }]]></xp:this.postNewDocument>
<xp:this.querySaveDocument><![CDATA[#{javascript:querySaveDocument(); }]]></xp:this.querySaveDocument>
<xp:this.postOpenDocument><![CDATA[#{javascript: postOpenDocument();}]]></xp:this.postOpenDocument>
<xp:this.postSaveDocument><![CDATA[#{javascript: postSaveDocument()}]]></xp:this.postSaveDocument>
</xp:dominoDocument>
 
then would you not expect that computed fields on the form "Person" would be recomputed at some point between querySaveDocument and postSaveDocument ? I can see all the validation runs when the source saves as I use @VaildateInternetAddress on a couple of form fields and that all works fine. Reading the documentation for dominoDocument saysy that it does run the field validation on the form fields, but says nothing of computed field values.
 
Classic notes design says that the computeWithForm will refresh these computed field values when the method or@formula is called. 
 
Is this a change in behaviour to make xPages more efficient, and do I simply need to do a currentDocument.computeWithForm()  in my querySaveDocument, or is there a more efficient method for updating computed field values ?
 
Many thanks in advance 
 
Simon Delicata 
Jun 1, 2011, 10:56 AM
54 Posts
Re: Forms and computed fields
 I have used the "computedWithForm" property successfully sofar (with version 8.5.2).
I guess you've found the setting already?  data => data => dominoDocument[0] => computeWithForm => onload / onsave / both  (I've used the 'onsave' value).
 
No extra method call is needed to make the form compute to happen.
 
Did I missunderstand your question? :)
 

Jun 1, 2011, 4:06 PM
3 Posts
Re: Forms and computed fields
 Hi Rami
 
No you didn't. I think my database is broken somewhere.  
 
thanks 
 
Simon 
Jun 1, 2011, 11:03 AM
261 Posts
Re: Forms and computed fields
Simon,
 
Since starting developing using XPages I try to stay away from computed fields and computeWithForm actions. If you add a SSJS library to your XPage and call (generic) functions from that library in the querySaveDocument to compute the fields you need, everything is a lot easier to read/ understand/ maintain.

You're right however in your assumption: a computeWithForm should occur after the querySaveDocument event and before the postSaveDocument. I did some tests with your code and found out that you're right: the computeWithForm didn't occur at all. After I changed the "onboth" to just "onsave" everything suddenly did work as expected. I can't explain it, but do you really need to have the computeWithForm set to "onboth'? If not then this is a solution for you.
 
Mark

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal