The below post is all about closing child window and refreshing parent window after updating record.
http://salesforceworld4u.blogspot.in/2015/06/closing-child-window-and-refreshing.html
But let's think there is a requirement like we have to validate before updating and closing child window then above approach wont work.
For the above requirement we have to pass javascript code in pagereference method instead of calling javascript on button click.
public PageRefeRence savingAccount(){
PageRefeRence pageRef ;
if(account.name == ''){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Error,'You must enter some value...');
ApexPages.addMessage(myMsg);
}
else{
upsert account;
}
pageRef = new PageReference('javascript:window.opener.location.href='+'\'/'+account.ID+'\';window.close();');
return pageRef ;
http://salesforceworld4u.blogspot.in/2015/06/closing-child-window-and-refreshing.html
But let's think there is a requirement like we have to validate before updating and closing child window then above approach wont work.
For the above requirement we have to pass javascript code in pagereference method instead of calling javascript on button click.
public PageRefeRence savingAccount(){
PageRefeRence pageRef ;
if(account.name == ''){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Error,'You must enter some value...');
ApexPages.addMessage(myMsg);
}
else{
upsert account;
}
pageRef = new PageReference('javascript:window.opener.location.href='+'\'/'+account.ID+'\';window.close();');
return pageRef ;
1 comment:
This will also work
return new PageReference('javascript:window.top.close();');
Post a Comment