2

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.

3
  • Ok so just so I understand, you click the button from the standard account page, which opens VF page in a new window? And on update of the salary, you want to close the popup window (your VF page) and refresh the standard account page. Nov 29, 2013 at 13:06
  • Yes.. exactly...
    – NaveenRaw
    Nov 29, 2013 at 13:09
  • ok added something that hopefully helps Nov 29, 2013 at 13:21

1 Answer 1

6

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.

5
  • 1
    Great, glad to help :) Nov 29, 2013 at 13:31
  • 1
    I want to add something in here... i also used the same method that u have written but it was not working as my development mode was on. So i suppose that is also a new learning for me. :)
    – NaveenRaw
    Nov 29, 2013 at 13:42
  • @sfdc_ninja Awesome answer . Nov 29, 2013 at 13:48
  • @sfdc_ninja window.opener.location.href is not working in IE. In mozilla and chrome it works fine but not in IE. any change required in this?
    – NaveenRaw
    Feb 17, 2014 at 10:23
  • I have been using same code it works with firefox , chrome but in IE it opens a new tab.
    – user7724
    Jan 8, 2015 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.