I have a button that updates an opportunity. When it is complete the page refreshes but doesn't reload with updated data here is my code:


 public class ContractDetails{
            public Opportunity ThisOpportunity{get;set;}  
            public string oppid {get;set;}
            public string requested {get;set;}

       public ContractDetails(){
            oppid = ApexPages.currentPage().getParameters().get('id');
            requested = ApexPages.currentPage().getParameters().get('requested');
            string selected = 'background-color:#4bca81;color:white';

                            oppid = ApexPages.currentPage().getParameters().get('oppidd');
            ThisOpportunity = [Select Contract_Requested__c FROM Opportunity where ID=:oppid];
            if(ThisOpportunity.Contract_Requested__c == boolean.valueOf('true')){
                requested = selected;
       public void save(){
                    ThisOpportunity.Contract_Requested__c = boolean.valueOf('True');
                    update ThisOpportunity;


<apex:page controller="ContractDetails"  showHeader="false" standardStylesheets="false" sidebar="false" docType="html-5.0" >
  <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <apex:slds />
  <script type="text/javascript">
            function requested(){
            function rerender(){
  <apex:form id="wf">
  <button class="slds-badge" style="{!requested}" onclick="requested()">Requested
       <apex:actionfunction action="{!save}" name="requesteoper" oncomplete="rerender()"></apex:actionfunction></button></apex:form>

I would expect the {!requested} to be loaded with the selected variable on the reload, but it appears it doesn't rerun the sobject query in the main function.

How do I get this to rerun?

The page refreshes then runs the method in the controller in a separate operation, see log below: enter image description here

1 Answer 1


Your guess is right..

Since you are doing a partial load using action function and rerender and not reloading the entire page, your controllers constructor will not run and so the object is not getting reinitialised after the update.

you can move the initialization part into a helper method and call it from both the constructor and from the save method after updating the record.

  • So, when i click the button the page refreshes then in a separate operation runs the function in the method in the controller. I added an oncomplete to the apexactionfunction but it never performs it, shouldn't this be able to rerender the page? Jul 3, 2017 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .