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
affuaffu 

How to get values in visualforce page

Hi all,

 

I have written a Visualforce PDF with extension class to call the list of contacts and a button on Button on Opportunity pagelayout .

The buttons works as if stagename == site visit it should give an error else open the PDF.

But here the problem is onclick javascript is working properly but im not getting the CONTACT values in visualforce page.

Visualforce page and Button is on Opportunity 

 

 

Javascript:

var a = '{!Opportunity.StageName}'; 
if(a == 'Site Visit') 
alert('Please fill the Application Details');  
else 
window.open('/apex/Application_PDF?scontrolCaching=1&id={!Opportunity.Id}');

 Thanks in Advance...

KPKKPK

Can you elobarate your query?

 

Arjun1981Arjun1981

Hi,

 

I used the same code for Opportunity Detail button in my Dev org and I got the contact list in my Visualforce page which was rendered as PDF.

Please let me know your query in detail so that I can help you.

 

Thanks,

 

affuaffu

Hi Arjun,

 

Actually i was trying to get the list of contacts which should get the values in visualforce PDF, If i click on the button the page was opening but the contact values are not displaying. Did u used the same javascript in button?

 

I have a visualforce PDF in opportunity. In that PDF im calling fields from different objects like contacts,receipts....

so in in opportunity page button i gave onclick javascript as if status picklist is 'sitevisit' then the it should show an pop up window with an error message or open the PDF. here the problem is it is opening the PDF but the related object field values are getting displayed.

 

Thanku.

 

Arjun1981Arjun1981

Hi,

 

Yes, I used the same Java Script code in my Opportunity detail button.

In my visualforce page I used <apex:repeat> tag to display the values from different objects.

Pls let me know your VF code so that I can help you.

 

Thanks.

 

 

affuaffu

Quit Big

<apex:page standardcontroller="Opportunity" showHeader="false" renderAs="pdf" extensions="PaymentSchedulePDF">
  <!-- Begin Default Content REMOVE THIS -->
  <head>
  <style type="text/css" media="print">
    @page {
        @top-right {
            content: element(header);
            size:landscape;
        }
        @PageBreak{
             page-break-after:always;
        }
        @bottom-right {
            content: element(footer);
        }
        
    div.header {
       
        text-align: right;
        position: running(header);
        padding: 2px;
        margin-right:80px;
        margin-left:80px;
        color:#000000;
       font-
    }
     
   
    .tableHead1 {
        background: #BABABA;
        vertical-align:text-top;
        font-weight:bold;
        border-left:0px solid #FFFFFF;
        border-right:0px solid #FFFFFF;
        border-top:0px;
        border-bottom:0px;
    }
</style>
</head>
  <div class="header">
  </div> 
  <div class="footer">
  </div>
      <img align="center" src='{!URLFOR($Resource.ApplicationLogo)}' height="110px"/>
          <table width="100%" border="0" cellspacing="0">          
              <tr>
                  <td width="20%" align="left" style="font-size:16px">
                      <apex:outputText value="Enquiry Reference No. {!Opportunity.Enquiry_Ref_No__c}" />    
                  </td>  
                  <td width="20%" align="right" style="font-size:16px;text-align:right">
                      <apex:outputText value="Application Date: {0,date,dd/MM/yyyy}">
                          <apex:param value="{!Opportunity.CloseDate}"/>
                      </apex:outputText>
                  </td>
              </tr>
          </table>
        
          <h1 width = "100%" colspan="6" align="center" style="font-size:16px; font-weight:bold; background-color:#FFCC00;">&nbsp;&nbsp;&nbsp;FIRST APPLICANT</h1>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable" styleClass="tableClass">
                  <apex:column >
                  </apex:column>    
              </apex:dataTable>
              <table width="20%" border="1" cellspacing="0" height="200" align="right">
                  <tr>
                      <td colspan="8" align="center" height="150" style="font-size:12px; font-weight:bold; ">Recent Photograph of 1st Applicant</td>
                  </tr>
              </table>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable1" styleClass="tableClass">
                  <apex:column >
                      Applicant's Name:<apex:outputText value="{!con.LastName}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Gender :<apex:outputText value=" {!con.Gender__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Date of Birth :<apex:outputText value=" {!con.Birthdate}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Marital Status :<apex:outputText value=" {!con.Marital_Status__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      No. of Dependents : <apex:outputText value="{!Round(con.No_of_Dependents__c,0)}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Nationality :<apex:outputText value=" {!con.Nationality__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Religion :<apex:outputText value=" {!con.Religion__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Caste : <apex:outputText value="{!con.Caste__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Qualification : <apex:outputText value="{!con.Qualification__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/>
                  </apex:column>
              </apex:dataTable>
          <h1 colspan="6" align="center" style="font-size:16px; font-weight:bold; background-color:#FFCC00;">&nbsp;&nbsp;&nbsp;Name</h1>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable2" styleClass="tableClass">
                  <apex:column >
                      Father/Spouse Name:<apex:outputText value="{!con.Father_Spouse_Name__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/>
                  </apex:column>
              </apex:dataTable>
          <h1 align="center" style="font-size:16px; font-weight:bold; background-color:#FFCC00;">&nbsp;&nbsp;&nbsp;Current Address</h1>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable3" styleClass="tableClass">
                  <apex:column >
                      Street:<apex:outputText value="{!con.MailingStreet}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      City:<apex:outputText value="{!con.MailingCity}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      State:<apex:outputText value="{!con.MailingState}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Phone:<apex:outputText value="{!con.MobilePhone}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Postal Code:<apex:outputText value="{!con.MailingPostalCode}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Phone:<apex:outputText value="{!con.Phone}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Country:<apex:outputText value="{!con.MailingCountry}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Email (Personal):<apex:outputText value="{!con.Email}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                  </apex:column>
              </apex:dataTable>
          <h1 style="font-size:16px; font-weight:bold; background-color:#FFCC00;">&nbsp;&nbsp;&nbsp;Permanent Address</h1>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable4" styleClass="tableClass">
                  <apex:column >
                      Street:<apex:outputText value="{!con.OtherStreet}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      City:<apex:outputText value="{!con.OtherCity}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      State:<apex:outputText value="{!con.OtherState}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Phone:<apex:outputText value="{!con.OtherPostalCode}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Postal Code:<apex:outputText value="{!con.MobilePhone}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Phone:<apex:outputText value="{!con.OtherCountry}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Country:<apex:outputText value="{!con.MailingCountry}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Email (Personal):<apex:outputText value="{!con.OtherPhone}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                  </apex:column>
              </apex:dataTable>
          <h1 colspan="6" align="center" style="font-size:16px; font-weight:bold; background-color:#FFCC00;">&nbsp;&nbsp;&nbsp;Occupation Details</h1>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable5" styleClass="tableClass">
                  <apex:column >
                      Occupation :<apex:outputText value="{!con.Occupation__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      PAN / GIR No. : <apex:outputText value="{!con.PAN_Card__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Gross Annual Income :<apex:outputText value=" {!Round(con.Gross_Annual_Income__c,0)}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Other Income :<apex:outputText value=" {!Round(con.Other_Income__c,0)}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Company Name :<apex:outputText value=" {!con.Company_Name__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                  </apex:column>
              </apex:dataTable>
              <div style="page-break-after:always;"> 
              </div> 
          <h1 colspan="6" align="center" style="font-size:16px; font-weight:bold;">Office Address</h1>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable6" styleClass="tableClass">
                  <apex:column >
                      <apex:outputText value="{!con.Location_Work_Add__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      <apex:outputText value="{!con.Street__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      <apex:outputText value="{!con.City__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      <apex:outputText value="{!con.Other_Income__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      <apex:outputText value="{!con.Cluster_Office_Address__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      <apex:outputText value="{!con.State__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      <apex:outputText value="{!con.PIN_CODE__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      <apex:outputText value="{!con.OtherPhone}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      <apex:outputText value="{!con.Country__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Email (Official) :<apex:outputText value=" {!con.Official_Email__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Designation :<apex:outputText value=" {!con.Title}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Years in Current Occupation / Business :<apex:outputText value=" {!Round(con.Years_in_Current_Occupation_Business__c,0)} Years" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Total Years in Occupation / Business :<apex:outputText value=" {!Round(con.Total_Years_in_Occupation_Business__c,0)} Years" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                      Preferred Mailing Address : <apex:outputText value="{!con.Preferred_Mailing_Address__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/><br/>
                  </apex:column>
              </apex:dataTable>
          <h1 colspan="6" align="center" style="font-size:16px; font-weight:bold; background-color:#FFCC00;">&nbsp;&nbsp;&nbsp;Type of Industry</h1>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable7" styleClass="tableClass">
                  <apex:column >
                      Type of Industry : <apex:outputText value="{!con.Type_Of_Industry__c}" rendered="{!con.Contact_Type__c =='Applicant'}"/>
                  </apex:column>
              </apex:dataTable>
          <h1 colspan="6" align="center" style="font-size:16px; font-weight:bold; background-color:#FFCC00;">&nbsp;&nbsp;&nbsp;Co-Applicant</h1>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable8" styleClass="tableClass">
                  <apex:column >
                      Relationship with the Applicant :<apex:outputText value=" {!con.Type_Of_Industry__c}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      Applicant's Name:<apex:outputText value="{!con.LastName}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                  </apex:column>            
              </apex:dataTable>       
              <table width="20%" border="1" cellspacing="0" height="200" align="right">
                  <tr>
                      <td colspan="8" align="center" height="150" style="font-size:12px; font-weight:bold; ">Recent Photograph of 1st Applicant</td>
                  </tr>
              </table>
              <apex:dataTable value="{!cont}" var="con" rowClasses="odd,even" id="theTable9" styleClass="tableClass">
                  <apex:column >
                      Gender:<apex:outputText value="{!con.Gender__c}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      Date of Birth:<apex:outputText value="{!con.Birthdate}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      Street:<apex:outputText value="{!con.MailingStreet}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      City:<apex:outputText value="{!con.MailingCity}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      State:<apex:outputText value="{!con.MailingState}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      Postal Code:<apex:outputText value="{!con.MailingPostalCode}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      Country:<apex:outputText value="{!con.MailingCountry}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      Phone : <apex:outputText value="{!con.Phone}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      Mobile : <apex:outputText value="{!con.MobilePhone}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                      Email (Personal) :<apex:outputText value=" {!con.Email}" rendered="{!con.Contact_Type__c =='Co - Applicant'}"/><br/>
                  </apex:column>
              </apex:dataTable>
          <h1 colspan="6" align="center" style="font-size:16px; font-weight:bold; background-color:#FFCC00;">&nbsp;&nbsp;&nbsp;Payment Details</h1>
              <apex:dataTable value="{!rcList}" var="rec" rowClasses="odd,even" id="theTable10" styleClass="tableClass">
                  <apex:column >
                      Cheque No. / Transaction ID. :<apex:outputText value=" {!rec.Transaction_No__c}" rendered="{!rec.Payment_Towards__c=='On Booking'}"/><br/>
                      Cheque / Transaction Date :<apex:outputText value=" {!rec.Instrument_Date__c}" rendered="{!rec.Payment_Towards__c=='On Booking'}"/><br/>
                      Bank Name :<apex:outputText value=" {!rec.Bank_Name__c}" rendered="{!rec.Payment_Towards__c=='On Booking'}"/><br/>
                      Amount : <apex:outputText value="{!Round(rec.Amount__c,0)}" rendered="{!rec.Payment_Towards__c=='On Booking'}"/><br/>
                  </apex:column>
              </apex:dataTable>
         
</apex:page>

 

Arjun1981Arjun1981

Hi,

 

I dont see any flaw in ur VF code.

Are you fetching all the fields from Contact and other objects in your controller?

use ur method as getContacts() and return the values to the vf page.

 

Thanks.