[SalesForce] Reload Visualforce Page After Update

I have a Visualforce page on a custom object that has a commandButton to update a field on the custom object. When that field is updated, a Process fires that then creates a case based on the information in the custom object record. All works fine. However, I would like to refresh the page once the Process fires. Is this possible?

CommandButton:

<apex:commandButton rendered="{!(CC.Create_Case__c == false)}" value="Create Case" action="{!CreateCase}" style="background:#d699ff; padding: 5px 10px 5px 10px"/>

Controller:

public with sharing class VF_Controller_CreateCampaignCase{

public Campaign_Create_Request__c CCR;

    public VF_Controller_CreateCampaignCase(ApexPages.StandardController myController){
        this.CCR = (Campaign_Create_Request__c)myController.getRecord();
    }

    public Void CreateCase() {
            CCR.Create_Case__c = true;
            update CCR;
    }
}

Best Answer

Thanks everyone. I got my problem resolved by changing the Void method in my controller to a PageReference method and then adding a redirect back to my current page. Thanks for all your help! Updated working code for my controller is below:

public with sharing class VF_Controller_CreateCampaignCase{

    public Campaign_Create_Request__c CCR;

    public VF_Controller_CreateCampaignCase(ApexPages.StandardController myController){
        this.CCR = (Campaign_Create_Request__c)myController.getRecord();
    }

    public PageReference CreateCase() {
        CCR.Create_Case__c = true;
        update CCR;

        PageReference tempPage = ApexPages.currentPage();            
        tempPage.setRedirect(true);
        return tempPage;
    }
}
Related Topic