function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pdopdo 

Close Popup and Refresh Parent

All I want to do is close the popup window and refresh the parent when my save is complete and nothing happens on this.  Can anyone help?

 

Page

<apex:page id="orderpage1" standardController="Order_Item_Junction__c" extensions="oitemController" sidebar="false" showheader="false" >
<script language="JavaScript" type="text/javascript">
function closeAndRefresh()
{
    window.close();
    window.opener.location.reload();
}
</script>
    <apex:form id="form1">
        <apex:pageBlock title="Add Order Items" id="order">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" action="CloseAndRefresh()" />
            </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbsbundle" title="Available Product Bundles" rendered="true" columns="1">
                    <apex:pageBlockTable id="pbtbundles" value="{!lstoitem}" var="l" width="100%">
                        <apex:column headerValue="Order" value="{!l.Order__c}" width="40%"/>
                        <apex:column headervalue="Product Bundle Name" value="{!l.Product_Bundle__c}" width="40%"/>
                        <apex:column headerValue="Quantity" id="iqty" width="20%">
                            <apex:inputField value="{!l.Quantity__c}"/>
                        </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" action="CloseAndRefresh()" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Best Answer chosen by Admin (Salesforce Developers) 
NiketNiket

Hi,

 

I would suggest to check "Development Mode" checkbox. If it is checked, I suspect your required functionality would not work. Try unchecked "Development Mode" checkbox on your profile.

 

Try this code as well :

 

<script language="JavaScript" type="text/javascript">
function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.id}";
      window.top.close();
      
  }
</script>

 

<apex:commandButton action="{!save}"  oncomplete="javascript&colon;CloseAndRefresh()"  value="Update" id="button"/>

 

Please try it once and let me know if you still face the issue.

 

Please mark it as the solution if it answers your question.

 

Ckeck My Blog

All Answers

sfdcfoxsfdcfox

Call reload first. window.close should not return, as the script is unloaded when this is called.

NiketNiket

Hi,

 

I would suggest to check "Development Mode" checkbox. If it is checked, I suspect your required functionality would not work. Try unchecked "Development Mode" checkbox on your profile.

 

Try this code as well :

 

<script language="JavaScript" type="text/javascript">
function CloseAndRefresh(){
window.opener.location.href="/{!$CurrentPage.parameters.id}";
      window.top.close();
      
  }
</script>

 

<apex:commandButton action="{!save}"  oncomplete="javascript&colon;CloseAndRefresh()"  value="Update" id="button"/>

 

Please try it once and let me know if you still face the issue.

 

Please mark it as the solution if it answers your question.

 

Ckeck My Blog

This was selected as the best answer
pdopdo

Thnaks Niket,

This helped.  IT is using a custom action so I had to modify.  Here is my final page:

<apex:page id="orderpage1" standardController="Order_Item_Junction__c" extensions="oitemController" sidebar="false" showheader="false" >
<script language="JavaScript" type="text/javascript">
function CloseAndRefresh()
{
    window.opener.location.href="/{!$CurrentPage.parameters.oid}";
    window.top.close();
      
}
</script>
    <apex:form id="form1">
        <apex:pageBlock title="Add Order Items" id="order">
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" onclick="CloseAndRefresh()" />
            </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbsbundle" title="Available Product Bundles" rendered="true" columns="1">
                    <apex:pageBlockTable id="pbtbundles" value="{!lstoitem}" var="l" width="100%">
                        <apex:column headerValue="Order" value="{!l.Order__c}" width="40%"/>
                        <apex:column headervalue="Product Bundle Name" value="{!l.Product_Bundle__c}" width="40%"/>
                        <apex:column headerValue="Quantity" id="iqty" width="20%">
                            <apex:inputField value="{!l.Quantity__c}"/>
                        </apex:column>
                    </apex:pageBlockTable>
                </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton value="Save" action="{!saveitems}" oncomplete="CloseAndRefresh()" />
                <apex:commandButton value="Cancel" onclick="CloseAndRefresh()" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

HariPHariP

Hi,

 

I have similar problem. My page has some input fileds and a related list. I have added a custom button for related list and I am opening a popup (VisualForce page) for related list. After closing popup, I want to reload just the related list section to show the new changes.

 

Any help appreciated.

 

Thanks

 

pdopdo

Here is the end code I used for both the class and the page.  Check it out.

 

http://boards.developerforce.com/t5/Apex-Code-Development/Junction-Object-Class/m-p/383455#M68652

vivekanandanvivekanandan

I have the same situation, I have a page consists of check boxes and and a button, on clicking of that button it will generate a PDF,

When i close the PDF and uncheck some of the check boxes, then click on button , the pdf is not dsplayed based on my selection.

 

second time when i close the pdf and click on the button again, it is getting displayed based on my  previous selection.

 

Please help me . this is very urgent.