I have a Visualforce (child page) stored within a Standard Page layout (Opportunity parent standard page) which calls a custom controller "Save" method.

I would like for the parent page to refresh/reload automatically after the "Save" Command button is clicked on the child VF page. Is this possible?


<apex:commandButton value="Save" action="{!saveConditions}" disabled=" 
{!if((Opportunity.ApprovalStatus__c ='' || Opportunity.ApprovalStatus__c 
='Recalled' || Opportunity.ApprovalStatus__c ='Rejected') ,'false','true')}" 
rendered="{!Conditions.size>0}" status="actStatusId" reRender="pgBlckId" />  

Controller (saveConditions) method:

    public pageReference saveConditions(){
    try {
        List<Pricing_Condition__c> temp = new List<Pricing_Condition__c>();
        for(ConditionWrapper A : Conditions) temp.add(A.Condition); 
        upsert temp; 

    //}catch(dmlException E){ ApexPages.addMessage(new 
    ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage())); }  
    } catch (DMLException ex){

    String errorMessage = ex.getMessage();
    Integer occurence;
    if (ex.getMessage().contains('FIELD_CUSTOM_VALIDATION_EXCEPTION')){
    occurence = errorMessage.indexOf('FIELD_CUSTOM_VALIDATION_EXCEPTION,') + 
    errorMessage = errorMessage.mid(occurence, errorMessage.length());
    occurence = errorMessage.lastIndexOf(':');
    errorMessage = errorMessage.mid(0, occurence);
        else {
                errorMessage = ex.getMessage();
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 
return null;


1 Answer 1


There is no straight forward way by which you can do that. But there is a workaround for that where we can set window.top.location.href to refresh the entire page.

Inline visualforce page

<apex:page standardController="Opportunity" extensions="OpportunityExtn" > 
    <apex:form > 
        <apex:commandButton value="Save" action="{!saveConditions}" disabled="{!if((Opportunity.ApprovalStatus__c ='' || Opportunity.ApprovalStatus__c ='Recalled' || Opportunity.ApprovalStatus__c ='Rejected') ,false,true)}"  status="actStatusId" rendered="{!conditions.size>0}" reRender="pgBlckId,redirectPanel" /> 
        <apex:outputPanel id="redirectPanel" > 
            <apex:outputText rendered="{!shouldRedirect}"> 
                <script type="text/javascript"> 
                    window.top.location.href = '{!redirectUrl}'; 

Controller extension

public class OpportunityExtn { 
    private ApexPages.StandardController stdController; 
    public String redirectUrl {public get; private set;} 
    public Boolean shouldRedirect {public get; private set;} 
    public OpportunityExtn(ApexPages.StandardController stdController) { 
        this.stdController = stdController; 
        shouldRedirect = false; 
    public PageReference saveConditions() { 
            shouldRedirect = true; 
            redirectUrl = stdController.view().getUrl(); 
            //All your save logic in try
        } catch (Exception ex){               
            shouldRedirect = false; 
            redirectUrl ='';
            //All the catch logic
        return null; 
  • Thanks for your response @vijay ganji. Is there a native solution that comes to mind? I'd rather not go the JS route given my org will be moving to Lightning at some point in the future and could encounter some compatibility issues.
    – FWSFDC
    Aug 14, 2019 at 19:54
  • This does work, however!
    – FWSFDC
    Aug 14, 2019 at 20:12

You must log in to answer this question.

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