[SalesForce] CommandButton Refresh Page

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?

Controller:

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.');
        approve1.setObjectId(myDS.id);

        approve1.setProcessDefinitionNameOrId(null);
        approve1.setSkipEntryCriteria(true);

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

        PageReference RetPage = ApexPages.currentPage();
        RetPage.setRedirect(true);
       return RetPage; 
    }
}

Best Answer

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.

Related Topic