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
Vignesh RamshettyVignesh Ramshetty 

unable to decleare child objects fields getting Error: Unknown property 'VisualforceArrayList.Life_Insurances__r'

APEX CLASS :
Public with sharing  class viewholderdetails{


   public string name{set;get;}
 public list<Policy_Holder__c> Message {set;get;}
Public list<Policy_Holder__c> Message2 {set;get;}
      
 
     public void getdata() {
     
     
     
       Message = [SELECT id,(SELECT id, Name, Due_date__c, Premium_Start_Date__c,  Premium_End_date__c, Premium_Type__c, Total_amt_paid__c FROM Life_Insurances__r)
      
FROM Policy_Holder__c WHERE Policy_ID__c =: name];
  
  Message2 = [SELECT id,(SELECT id, Name, Due_date__c, Premium_Start_Date__c,  Premium_End_date__c, Premium_Type__c, Total_amt_paid__c FROM Motor_Insurances__r)
      
FROM Policy_Holder__c WHERE Policy_ID__c =: name];
  
  }
     
        }


Visualforce page :

<apex:page Controller="viewholderdetails">
    <apex:form >

   <apex:pageBlock title="Life Insurance Project">
        <apex:pageMessages />
       <apex:pageBlockSection title="Insurance datiles">
           
           
            Enter Policy holder ID :<apex:inputtext value="{!name}"/>  
         
           
 

           <apex:commandButton value="Submit"   action="{!getdata}"/>
       
         </apex:pageBlockSection>  
 
          <apex:pageBlock >
           <apex:pageMessages />
         
                     
                      <apex:pageBlockTable value="{!Message.Life_Insurances__r}" var="me" >
 
                     
                     <apex:column value="{!me.Name}" />  
                     <apex:column value="{!me.Due_date__c}"/>
                     <apex:column value="{!me.Premium_Start_Date__c}"/>
                     
                       
                      <apex:column value="{!me.Premium_End_date__c}"/>
                      <apex:column value="{!me.Premium_Type__c}"/>
                            <apex:column value="{!me.Total_amt_paid__c }">
      </apex:column>
                       
                       

               
                </apex:pageBlockTable>
                 </apex:pageBlock >
                 
                 
                 <apex:pageBlock >
         
                  <apex:pageBlockTable value="{!Message2.Motor_Insurances__r}" var="m1" >
 
 
                     
                     <apex:column value="{!m1.Name}" />  
                     <apex:column value="{!m1.Due_date__c}"/>
                     <apex:column value="{!m1.Premium_Start_Date__c}"/>
                     
                       
                      <apex:column value="{!m1.Premium_End_date__c}"/>
                      <apex:column value="{!m1.Premium_Type__c}"/>
                            <apex:column value="{!m1.Total_amt_paid__c }">
      </apex:column>
                       
                       

               
                </apex:pageBlockTable>
 
                     
           
                       
                       
 </apex:pageBlock >
               
                         
                         
                    </apex:pageBlock>  

               
                                           
    </apex:form>
</apex:page>
Best Answer chosen by Vignesh Ramshetty
mukesh guptamukesh gupta
Hi VIgnesh,

Please use below code:-
 
<apex:page Controller="viewholderdetails">
    <apex:form >

   <apex:pageBlock title="Life Insurance Project">
        <apex:pageMessages />
       <apex:pageBlockSection title="Insurance datiles">
           Enter Policy holder ID :<apex:inputtext value="{!name}"/>  
         <apex:commandButton value="Submit"   action="{!getdata}"/>
       </apex:pageBlockSection>  
 
          <apex:pageBlock >
           <apex:pageMessages />
		   
		   <apex:repeat value="{!Message}" var="msg">
			<apex:pageBlockTable value="{!msg.Life_Insurances__r}" var="me" >
				 <apex:column value="{!me.Name}" />  
				 <apex:column value="{!me.Due_date__c}"/>
				 <apex:column value="{!me.Premium_Start_Date__c}"/>
				 <apex:column value="{!me.Premium_End_date__c}"/>
				 <apex:column value="{!me.Premium_Type__c}"/>
				 <apex:column value="{!me.Total_amt_paid__c }"></apex:column>
			</apex:pageBlockTable>
		  </apex:repeat>
          </apex:pageBlock >
                 
                 
		 <apex:pageBlock >
			 <apex:repeat value="{!Message2}" var="msg2">
				<apex:pageBlockTable value="{!msg2.Motor_Insurances__r}" var="me2" >
				 <apex:column value="{!me2.Name}" />  
				 <apex:column value="{!me2.Due_date__c}"/>
				 <apex:column value="{!me2.Premium_Start_Date__c}"/>
				 <apex:column value="{!me2.Premium_End_date__c}"/>
				  <apex:column value="{!me2.Premium_Type__c}"/>
				 <apex:column value="{!me2.Total_amt_paid__c }"> </apex:column>
				</apex:pageBlockTable>
			  </apex:repeat>
		</apex:pageBlock >

      </apex:pageBlock >                                     
    </apex:form>
</apex:page>


if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

All Answers

mukesh guptamukesh gupta
Hi VIgnesh,

Please use below code:-
 
<apex:page Controller="viewholderdetails">
    <apex:form >

   <apex:pageBlock title="Life Insurance Project">
        <apex:pageMessages />
       <apex:pageBlockSection title="Insurance datiles">
           Enter Policy holder ID :<apex:inputtext value="{!name}"/>  
         <apex:commandButton value="Submit"   action="{!getdata}"/>
       </apex:pageBlockSection>  
 
          <apex:pageBlock >
           <apex:pageMessages />
		   
		   <apex:repeat value="{!Message}" var="msg">
			<apex:pageBlockTable value="{!msg.Life_Insurances__r}" var="me" >
				 <apex:column value="{!me.Name}" />  
				 <apex:column value="{!me.Due_date__c}"/>
				 <apex:column value="{!me.Premium_Start_Date__c}"/>
				 <apex:column value="{!me.Premium_End_date__c}"/>
				 <apex:column value="{!me.Premium_Type__c}"/>
				 <apex:column value="{!me.Total_amt_paid__c }"></apex:column>
			</apex:pageBlockTable>
		  </apex:repeat>
          </apex:pageBlock >
                 
                 
		 <apex:pageBlock >
			 <apex:repeat value="{!Message2}" var="msg2">
				<apex:pageBlockTable value="{!msg2.Motor_Insurances__r}" var="me2" >
				 <apex:column value="{!me2.Name}" />  
				 <apex:column value="{!me2.Due_date__c}"/>
				 <apex:column value="{!me2.Premium_Start_Date__c}"/>
				 <apex:column value="{!me2.Premium_End_date__c}"/>
				  <apex:column value="{!me2.Premium_Type__c}"/>
				 <apex:column value="{!me2.Total_amt_paid__c }"> </apex:column>
				</apex:pageBlockTable>
			  </apex:repeat>
		</apex:pageBlock >

      </apex:pageBlock >                                     
    </apex:form>
</apex:page>


if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
This was selected as the best answer
Vignesh RamshettyVignesh Ramshetty
Hi Mukesh,
          now able to get it now my VF page has been saved without any error. and able to get data.
Thank you,
Vignesh
mukesh guptamukesh gupta
Hi Vignesh,

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh