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
MC34MC34 

how can i show child object field on visualforce page?

Hi, I have a case object where custom object clarification quesions are child object of the case object. There is a field called as "Product number" on the clarification questrion. I want to show that field in VF template that is built on case object. How can i show this field on the VF template? 

MC34
ShirishaShirisha (Salesforce Developers) 
Hi,

Greetings!

You can use the code suggested to call the fields from parent to child and child to parent Object in the below thread:

https://developer.salesforce.com/forums/?id=9060G000000XbH5QAK

Referene:https://salesforce.stackexchange.com/questions/76802/accessing-child-records-field-in-vf-page-using-parent-object-as-standard-control

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Malika Pathak 9Malika Pathak 9

Hi,

Please Find The solution. how can i show child object field on visualforce page?

Visual Force

<apex:page controller="Young10ShowChildDataController">
 <apex:form >
    <apex:pageBlock title="Data">
     <apex:pageBlockTable value="{!clarificationquesionsList}" var="cq">
        <apex:column value="{!cq.Product_number__c}"/>
          <apex:column value="{!cq.case__c.CaseNumber}"/>
        </apex:pageBlockTable>
     
     </apex:pageBlock>
    
    
    </apex:form>
    
</apex:page>

Apex page
public class Young10ShowChildDataController {

     
    public List<clarification_quesions__c> clarificationquesionsList{
        get;
        set;
    }
    public  Young10ShowChildDataController(){
        clarificationquesionsList=new List<clarification_quesions__c>();
        clarificationquesionsList=[select id,Product_number__c,case__c.CaseNumber from clarification_quesions__c where Product_number__c!=null];
        
    }
}


I hope it will help you.Do changes according to your code.

If it will help you Please Mark Best Answer

MC34MC34
Hi Malika, sorry little slow on VF development.

so i have a VF page already for the template: 
 
<messaging:emailTemplate subject="kamper PO# {!relatedTo.EBS_PO_Number__c} Order on Hold Clarification Required. Case #{!relatedTo.CaseNumber}, Order #{!relatedTo.EBS_Order_Number__c}, {!relatedTo.ThreadID_FK__c}" 
recipientType="Contact"  relatedToType="case">

    <messaging:htmlEmailBody >

<html>

<style>
body {font-family: 'source sans pro';}
</style>



<p>Thanks for ordering from KAMPER! We can’t wait to complete your order, but first need some clarification.  Your order will be paused until the below details are received from the clarification request, so a quick response is greatly appreciated!  Please review the details about what we need below:</p>

    
   <li>Clarification Needed:{!relatedTo.Clarification_Description__c}</li>
    <li>PO Number: {!relatedTo.PO_Number__c}</li>
     <li>Order Number: {!relatedTo.EBS_Order_ID__c}</li>
     <li>Date: {!relatedTo.Clarification_Start_Date__c}</li>
     <li>Customer Name &amp; Number: {!relatedTo.Account.Name}/{!relatedTo.EBS_Account_Number__c}</li>
      <li>Line Description (If any):<br/>
      <b>{!relatedTo.Proof_Description__c}</b></li><br/>
{I WANT TO SHOW THE RELATED PRODUCT NUMBER FROM THE RELATED QUESTION HERE}
     
     <br/><c:clarificationQuestions rcaseID="{!relatedTo}"/><br/>
     
     
   



<p>All the best, <br/>
The KAMPER Customer Care Crew<br/></p>



<a href="https://www.KAMPER.com/US/" style="text-decoration:none;color:#456FB2;font-size:18px;font-family:Source Sans Pro Black,sans-serif;">KAMPER.com</a><br />
<span style="font-size:11px"><span style="color:black"><span style="line-height:.8;font-family:&quot;Source Sans Pro&quot;,sans-serif">You can check order status and inventory, estimate shipping, create a virtual sample or access case studies, test reports, images and templates. It&rsquo;s all there!</span></span></span>



</html>
    </messaging:htmlEmailBody>

</messaging:emailTemplate>

Can you please provide me how the edit will look like. 

Thanks a lot!