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
asish1989asish1989 

Problem in passing Id from popup window to existing page.

Hi Everyone

  I have designed a page which shows all Opportunity in pageblock table .When I click on Opportunity Name a popup window of anather page is appeared  which show all the Quote in a particular Opportunity .I have also displayed all product in particular Quote in that popupwindow.Now I want to  pass QuoteId from current window to existing window.I also want to close this window.please anyone suggest me because I am new In salesforce.

 

Here is My code

 

<apex:page controller="pcontactdetailcontroller">
<script type= "text/javaScript">
var newWin=null;
 function openLookupPopup(Id)
 {
 //alert('Lokup'+rId);
  var url="/apex/pcontactdetailpopup?Id=" + Id ;
  newWin=window.open(url, 'Popup','height=700,width=800,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=no,status=no');
  if (window.focus)
  {
   newWin.focus();
  }
    
     return false;
    }

</script>

<apex:pageBlockSection title="Opportunity Details">
                 <apex:outputPanel  rendered="{!Enable!='asish'}">
                      <p><B> Oppertunity Details</B> <apex:commandButton value="Add Opportunity" action="{!forOpportunity}" style="color:blue,font-weight:16"/></P>
                      <apex:pageBlockTable value="{!OpportunityContactRoles}" var="conopportunity"  cellpadding="2" border="1"  rowClasses="odd,even" styleClass="tableClass">
           
                           <apex:column headerValue="Order No">{!conopportunity.Opportunity.OrderNumber__c}</apex:column>
                           <apex:column headerValue="Close Date">{!conopportunity.Opportunity.CloseDate}</apex:column>
                           <apex:column headerValue="Oppertunity Name">
                              <apex:commandLink value="{!conopportunity.Opportunity.Name}" action="{!forQuote}" id="opptname" title="for Quote Details" style="color:blue" onclick="openLookupPopup('{!conopportunity.Opportunity.Id}' ); return false">
                                   <apex:param name="optId" value="{!conopportunity.Opportunity.Id}" />
                              </apex:commandLink>
                            </apex:column>
                            <apex:column headerValue="Action">
                                    
                               <apex:commandLink value="AddQuote" title="to add Quote" action="{!toAddQuote}" style="color:blue" >
                                   <apex:param name="optId" value="{!conopportunity.Opportunity.Id}" />
                               </apex:commandLink>
                            </apex:column>
                            
                     </apex:pageBlockTable>

 

This Is my first page code.I have sent OppertunityId to pcontactdetailpopup page.

 

Now my popup window page code is

<apex:page controller="pcontactdetailpopupcontroller">

<apex:form>
  <apex:pageBlock title="All Quotes">

  <apex:pageBlockSection title="Quote Details">
  <apex:outputPanel style="float:middle">
                    <p><B>OPPORTUNITY NAME</B>:&nbsp;{!Opt.Name}<br/>
               
                     <B> All Quotes </B></P>
                          <apex:pageBlockTable value="{!opt.Quotes}" var="Qut" cellpadding="2" border="1"  rowClasses="odd,even" >
                               <apex:column headerValue="Quote Number">{!Qut.QuoteNumber}</apex:column>
                               <apex:column headerValue="Status">{!Qut.Status}</apex:column>
                               <apex:column headerValue="Quote Date">{!Qut.ExpirationDate}</apex:column>
                               <apex:column headerValue="Quote Name">
                                    <apex:commandLink value="{!Qut.Name}" action="{!forProduct}" style="color:blue" title="for Product Details">
                                        <apex:param name="quoteId" value="{!Qut.Id}" />
                          
                                    </apex:commandLink>
                               </apex:column>
                               <apex:column headerValue="Action">
                                     <apex:commandLink value="AddProduct" title="to add Quote" action="{!toAddProduct2}" style="color:blue">
                                         <apex:param name="quoteId" value="{!Qut.Id}" />
                                      </apex:commandLink>
                           
                                </apex:column>
                        
                        </apex:pageBlockTable>

 

<apex:commandButton value="Turn Quote Into Order" action="{!forOrder}" style="float:left"  onclick="window.top.close();"/>

Here simply window is closed.But I want to pass QuoteId to existin window.For this propose I have written methode in controller class.

public Id quoteId{get;set;}

public Pagereference forOrder() {

 

quoteId = ApexPages.currentPage().getParameter.get('quoteId');

PageReference samePage = new Paferefernce('/apex/pcontactdetailpopup?Id='+quoteId);

return samePage;

}

I think window is closed by java script.window.top.close();

.After that the controller method may not be executed.But I knew that controller method is executed after java script method.

please suggest me as soon as possible.

 

 

 

 

 

Navatar_DbSupNavatar_DbSup

Hi,


Use oncomplete instead of onclick inside the commandbutton and rerender the outputpanel. If possible then try to use same controller for both the pages. Your commandbutton code be like this (Don’t forget to mention an Id for the Outputpanel):
<apex:commandButton value="Turn Quote Into Order" action="{!forOrder}" rerender=”Outputpanelid” style="float:left" oncomplete="window.top.close();"/>


You can also go through this link:


http://boards.developerforce.com/t5/Visualforce-Development/What-is-wrong-Passing-a-parameter-to-the-parent-window-from-a/m-p/298731/highlight/true#M37446

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

asish1989asish1989

Hi  I did what you suggested.I have written oncomplete instead of onclick.I have also used same controller for both page.I could not know which outputpanel should be refressed.I mean in which outputpanel i have to write id = "outputpanelId" .I have passed two Id to popup page.one contactId and OpportunityId because in popup page , I want all the Quote of a particular Opportunity will be displayed.Now I want to pass QuotoId from popup page to existing page. But an Error is fired without window is being closed.

 

System.StringException: Invalid id: :0039000000A18YNAAZquoteId=:null
Class.pcontactdetailcontroller.getOpportunityContactRoles: line 142, column 17 External entry point.

I have written getOpportunityContactRoles() method to display all Opportunity of a particular contact in a datatable.code is

 

public List<OpportunityContactRole> getOpportunityContactRoles() {
     
             Id Id = ApexPages.currentPage().getParameters().get('Id');
              optcList=[select Id,ContactId,OpportunityId,Opportunity.CloseDate,Opportunity.Name,Opportunity.OrderNumber__c   from OpportunityContactRole  where ContactId=:Id order by createdDate desc];
              return optcList;
               }

Error is fired on Id Id = ApexPages.currentPage().getParameters().get('Id'); on this line...........

please help me if anyone have suggestion.

 

asish1989asish1989

Hi

I apologize because there was syntax error in my code.I had forgot to write &quoteId thats why Invalid Id error was  being fired. The correct Syntax is

 PageReference newpage = new PageReference('/apex/pcontactdetail?Id='+Id+'&quoteId='+quoteId);

return newpage;

By writing this error is removed but window is simply closed quoteId can not not be passed. I want to pass quoteId .I have checked by System.debug statement

" PageReference newpage = new PageReference('/apex/pcontactdetail?Id='+Id+'&quoteId='+quoteId);" this line is executed. But why Id is not being passed.I think window is simply closed by javascript function.what is the advantage of executing  controller method in apex class.we all know two function can be executed by same event javascript method and apex method .But here why I am not able to send quoteId.please help me. I am new in this area  .you are my last hope so help me as soon as possible