function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
labaulabau 

Formulas not evaluating in partial page refreshes

Hello All!

 

I've set up a VF page to take inputs from the user, save the information, and return values based on a formula using a partial page refresh.

 

The formula will evaluate and return correctly the first time, but if changes are made to the inputs, the formula does not re-evaluate. See the code below - this seems like it should be pretty basic. Anyone have an idea how to fix it?

 

 

<apex:page standardController="TQuote__c" apiVersion="14.0"> <apex:form > <apex:pageBlock id="in" title="Edit Quote for {!$User.FirstName}"> <apex:pageMessages /> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!quickSave}" rerender="out, in" status="status"/> </apex:pageBlockButtons> <apex:pageBlockSection > <apex:inputField value="{!TQuote__c.ColLoc1__c}"/> <apex:inputField value="{!TQuote__c.ColLoc2__c}"/> <apex:inputField value="{!TQuote__c.ColLoc3__c}"/> <apex:inputField value="{!TQuote__c.Dollar_Value__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> <apex:pageBlock id="out" title="Read View"> <apex:actionStatus startText="updating..." id="status"/> <apex:pageBlockSection > <apex:outputField value="{!TQuote__c.name}"/> <apex:outputField value="{!TQuote__c.ColLoc1__c}"/> <apex:outputField value="{!TQuote__c.ColLoc2__c}"/> <apex:outputField value="{!TQuote__c.ColLoc3__c}"/> <apex:outputField value="{!TQuote__c.ScrSet__c}"/> <apex:outputField value="{!TQuote__c.Id}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:page>

 In the above, ScrSetup__c is a formula field that does a simple calculation based on the ColLoc__c fields. I have been trying to reconcile this for days - any help would be greatly appreciated!

 

 

TehNrdTehNrd

I might be blind but I don't see a field called ScrSetup__c, did you mean ScrSet__c?

 

When you say it returns correctly the first time do you mean on page load or the first time you clikc the save button?

labaulabau

Sorry - yes I should have said ScrSet__c, my bad!

 

As for returning correctly the first time - it evaluates and returns the correct value after the first save. However, on subsequent saves it does not recalculate the value. The static fields will update with their new values, but the formula field will remain the same value as the first calculation. It is as if it can only do a single formula evaluation.

TehNrdTehNrd

That is strange it works the first time you click the save button but not the second. It sort of suprises me it works at all. May want to open a case for this.

 

I'm not to familar with how formula fields work with standard controllers but with custom controllers they will not re-evaluate on a rerender ever. The only way to get the updated value is perform a DML and then requery. You can also build psudeo formula field logic into the controller.

 

Try removing the rerender attributes. This will cause the enitre page to reload but it may force the standard controller to requery the fields.

 

-Jason

Message Edited by TehNrd on 06-19-2009 01:30 PM
labaulabau
Thanks so much for the advice - I'll give that a shot!
labaulabau

I did try removing the AJAX components, but with the same result. I'd like to try a DML query - any idea if this is possible using only VisualForce? Or will it require an Apex extension? I don't know Apex, so I'm hoping I can avoid that route!

 

Thanks!