0

I have a inline vf page on some X object, when I click on the "Add" button of vf page a new window in will open as a pop up displaying other page. After adding the products on click of save, i want to refresh the detail page but not the inline vf page. I have tried all possible ways and I am finding no way out of this.

Any help on this will be great!!

=========================

Inline VF page

<apex:page standardController="Credit_Note__c" extensions="CreditNoteProductDisplay" showHeader="false" sidebar="false">
<apex:form >

<div style="text-align:center;display:block;">
  <apex:commandButton value="Add Product" onclick="window.open('//cs81.salesforce.com/apex/SaveCreditNoteProducts?Id={!$CurrentPage.parameters.Id}','_blank','height=400,location=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=1', 1);" rendered="{!noProductsAdded}"/> 
</div>
<br/>
 <apex:facet name="header">Product information</apex:facet>
    <apex:dataTable value="{!displayCreditNoteProducts}" var="creditDetails" align="Center" width="100%" cellpadding="4" cellspacing="10" id="OrderData" rendered="{!productsAdded}">
                <apex:column >
                    <apex:facet name="header">Product Name</apex:facet>
                    <apex:outputText value="{!creditDetails.Product__r.name}"/>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">Quantity</apex:facet>
                    <apex:outputText value="{0,Number,###,###,##0}">
                        <apex:param value="{!creditDetails.Quantity__c}"/>
                    </apex:outputText>
                </apex:column>
                <Apex:Column >
                    <apex:facet name="header">Credit Amount</apex:facet>
                    <apex:outputText value="{0,Number,###,###,##0.00}">
                       {!currencyCode}&nbsp;<apex:param value="{!creditDetails.Credit_Amount__c}"/>
                    </apex:outputText>
                </apex:column>
                <apex:column >
                    <apex:facet name="header">Total Amount</apex:facet>
                    <apex:outputText value="{0,Number,###,###,##0.00}">
                        {!currencyCode}&nbsp;<apex:param value="{!creditDetails.Quantity__c*creditDetails.Credit_Amount__c}"/>
                    </apex:outputText>
                </apex:column>
    </apex:dataTable>
</apex:form>
</apex:page>

Pop up Vf page

<apex:page showHeader="false" sidebar="false" controller="SaveCreditNote" id="p1">
<apex:form id="mainForm">
<script>
        function cancel(){
                window.opener.location.href="/{!$CurrentPage.parameters.id}";
                window.top.close();        
        }        

        function isNumberKey(evt) {
            var keyCode = (evt.which) ? evt.which : evt.keyCode;
            if ((keyCode >= 48 && keyCode <= 57) || (keyCode == 8))
                return true;
            else if (keyCode == 46) {
                var curVal = document.activeElement.value;
                if (curVal != null && curVal.trim().indexOf('.') == -1)
                    return true;
                else
                    return false;
            }
            else
                return false;
      }

      function myClose()
      {
          var excepT=Boolean({!closeBrowFlag});
          if(excepT)
          {
             window.opener.location.href="/{!$CurrentPage.parameters.id}";
             window.top.close(); 
          }
      }


</script>    
    <div  style="display: block;text-align: center;padding-top:20px;">
        <apex:commandButton value="Save"  action="{!getsaveCreditNoteDetails}" oncomplete="myClose();" reRender="mainForm"/>
        <apex:commandButton value="Cancel" onclick="cancel();"/>
    </div>
    <br/>   
    <div style="color:red;font-weight:bold;text-align:center;display:block;"> 
    <apex:outputText rendered="{!isError}">Please select a product/s and enter the amount</apex:outputText>
    <br/>
    </div>
    <apex:pageBlock title="Product Information">

    <apex:pageBlockTable value="{!creditNoteList}" var="cnl" width="100%" >
         <apex:column headerValue="Product Name">
             <apex:inputCheckbox value="{!cnl.isSelected}" />
             <apex:outputText value="{!cnl.productName}"/> <br/>
             <apex:outputLabel value="Please select product" rendered="{!cnl.errormsg1}" style="color:red;font-weight:bold;" id="prodError"/>
        </apex:column>

        <apex:column headerValue="Total Price (From Invoice)">
            <apex:outputText value="{!cnl.totalPrice}"/> 
        </apex:column>

        <apex:column headerValue="Quantity">
            <apex:outputText value="{!cnl.quantity}"/>
        </apex:column>
        <apex:column headerValue="Credit Amount">
             <apex:inputtext value="{!cnl.amount}" id="theTextInput" onkeypress="return isNumberKey(event,this);" /><br/>
             <apex:outputLabel value="Please enter amount" rendered="{!cnl.errormsg}" style="color:red;font-weight:bold;" id="amountError"/>
             <apex:outputLabel value="Amount can't be greater than Product total price" rendered="{!cnl.invoiceAmountGreater}" style="color:red;font-weight:bold;" id="amountGreater"/>
        </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>    
</apex:form>
</apex:page>
  • 1
    Can you share the code. – Tushar Sharma Jun 26 '16 at 16:34
  • @TusharSharma added the code!! I really don't understand what else I can do to close the window? Stuck up with from past 6 hrs. Not able to find any solution! – Praveen Biyani Jun 26 '16 at 16:45
  • I tried the above URL too.. Not working – Praveen Biyani Jun 26 '16 at 17:43
  • @PraveenBiyani - "i want to refresh the detail page but not the inline vf page" - You cannot refresh the detail record containing the inline page without also refreshing the inline page.. – Eric Jan 30 '17 at 14:27
0

You cannot refresh the detail page containing the inline page without refreshing the inline page as well.

To refresh the detail page from the popup use this to close the popup

function myClose() {
     var winOpener=window.opener;
      if (winOpener){
            winOpener.parent.location='/{!$CurrentPage.parameters.id}';
        }
      window.close();
   }

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.