[SalesForce] how to refresh parent from child if parent is account detail page

I have a use case to add a custom button on account detail page, on click of which a VF page opens up in which i will input value say salary and that will update the account record. Now what i want is that on saving the salary in my VF page i want to refresh the parent(i.e. the account record detail page) and then close the child.
I have tried all the option that was given in many related Q&A but nothing worked for me.

Did anybody faced this issue..

P.S. when i am doing this from one VF page to another VF page than the parent is getting refreshed, i suppose there is some problem with standard detail page where i have the button.

Best Answer

In your VF page, you just need to add a bit of javascript in the oncomplete of your commandbutton

Your button

<apex:commandButton value="saveSalary" action="{!yourSaveMethod}" oncomplete="myClose();"/>

JS method

function myClose(){
    window.opener.location.href="/{!$CurrentPage.parameters.yourAccountIdParamName}";
    window.top.close();
    //you could also use self.close();    
}

This is assuming you used a param to pass the accountID to the VF page.

Related Topic