I have a VF page with a commandbutton. I am trying to get the page to refresh once the commandbutton is clicked. The code below does what it is supposed to do, but the page does not refresh. Does anyone know how I can do this?

<apex:commandButton action="{!approve}" oncomplete="window.opener.location.refresh();" styleClass="buttonStyle" style="background:#99C299; font-size:16pt; font-family:arial;" value="Submit for Final Approval"/>

I tried using the pageReference in my "Review" controller, but I'm still not getting a refresh. Am I doing something wrong?


public class DSReviewController {
    public Deal_Summary__c myDS;
    public DSReviewController(ApexPages.StandardController stdController){
        this.myDS = (Deal_Summary__c)stdController.getRecord();

    public pageReference approve() {

        Approval.ProcessSubmitRequest approve1 = new Approval.ProcessSubmitRequest();
        approve1.setComments('Submitting request for approval.');


        Approval.ProcessResult result = Approval.process(approve1);

        PageReference RetPage = ApexPages.currentPage();
       return RetPage; 
  • 1
    Are you embedding this page in a standard layout or is it a pop-up. The opener property returns the reference to the window or page that opened the current page. If you simply want to refresh your VF page, you can use window.location.reload() .
    – manjit5190
    Oct 14, 2015 at 20:58
  • 2
    You can also just have your approve method return a PageReference to the current page.
    – Adrian Larson
    Oct 14, 2015 at 21:48
  • 2
    @manjit_singh - In keeping with the new LEX framework, you will want avoid using window.location. Might as well stop using it now to future proof your work
    – Eric
    Oct 14, 2015 at 21:55
  • Thanks all. I think my issue is that I have a workflow field update that updates a variable. I would like the page to refresh automatically to show that update, but it seems that all the options I've tried update the page before the workflow field update occurs. Any idea how to get the page to refresh after the WF update?
    – J. Neilan
    Oct 15, 2015 at 2:24
  • @J.Neilan - The page refresh happen after the transaction to update the record is complete so if the record is updated the page will show the new values. Maybe post your current approve method? Did you check the record to make sure the field was updated? What to you mean by "updates a variable" Because at face value any "variables" will be reset on the page refresh as it reloads the page
    – Eric
    Oct 15, 2015 at 11:36

1 Answer 1


Just follow @Adrian Larson advice. buttons by default refresh page. As there will be DML operation on record (in your action) page will be returned with values after transaction - this mean all triggers and workflows.

  • Hi Artur, I did try that and updated my post to show the controller, but I'm still not getting a refresh. Any ideas?
    – J. Neilan
    Oct 15, 2015 at 16:22

You must log in to answer this question.

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