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
RICARDO PALMARICARDO PALMA 

How get a subquery field value in a Visual Force Page.

Hi, 
I'm tring to write a text file with this information:
Quote1
QuoteLineItem1
QuoteLineItem2
QuoteLineItem3 ....

Quote2
QuoteLineItem1
QuoteLineItem2
QuoteLineItem3 .... etc

I'm able to write all the info for Quote1 and Quote2 etc, but I'm not able to write the details info for each Quote after each Quote record.

I have a button calling a VF page calling a controller 
Here is my Class 
public class IDR
{

    public Media__c media {get;set;}
    public List <Quote> LstQuotes { get; set; }
    public List <QuoteLineItem> LstQuotelineitem { get; set; }
  
    public void fetch()
    {
     String theId =  Apexpages.currentpage().getparameters().get('City');
     String strMediaID =  Apexpages.currentpage().getparameters().get('MediaId');       
               
     media = [SELECT m.City_Code__c, m.Name, m.Current_Issue_Date__c FROM Media__c m WHERE City_Code__c =
     :theId];
 
   LstQuotes = [SELECT q.id,q.QuoteNumber, q.Ad_Name__c,q.Type__c, q.Size__c,  q.Version__c, q.Bleed_Code__c,
   (Select QuoteLineItem.Id, QuoteLineItem.QuoteId From QuoteLineItems)
   From Quote q
   where City_Code__c = :theId and q.Media_Name__c =: strMediaID];


       
  for(Quote q:LstQuotes )
   {
       for (QuoteLineItem qli : q.QuoteLineItems)
       {
           // I can see my subquery info here. Now how can I send it back to my VF page?
            system.debug('Quote Line Items Records ' + qli.id );
         
       }
   }
     
  }   

}
/*********/
Here is my VF page

<apex:page Controller="IDR" sidebar="false" action="{!fetch}" contentType="text/plain/#emp.txt" cache="false">

{"mediaCode":"{!media.City_Code__c}","mediaName":"{!media.Name}","issueDate":"
<apex:outputText value="{0,date,yyyyMMdd}">
<apex:param value="{!media.Current_Issue_Date__c}" />
</apex:outputText>","secondWrap":false,"ads":[

<apex:repeat value="{!LstQuotes}" var="Listrec">
{"adId":"<apex:outputText value="{!Listrec.QuoteNumber}" />
","filename"<apex:outputText value="{!Listrec.Ad_Name__c}" />
,"type"<apex:outputText value="{!Listrec.Type__c}" />
,"size"<apex:outputText value="{!Listrec.Size__c}" />
,"version"<apex:outputText value="{!Listrec.Version__c}" />
,"section"<apex:outputText value="{!Listrec.Ad_Name__c}" />
,"bleedCode"<apex:outputText value="{!Listrec.Bleed_Code__c}" />
,"properties":["propertyid":

<apex:repeat value="{!LstQuotelineitem}" var="Listrec2">
// I think my details records have to be here.
</apex:repeat>

</apex:repeat>


</apex:page>

Thanks...

Best Answer chosen by RICARDO PALMA
Shyam BhundiaShyam Bhundia
try doing 
<apex:repeat value="{!Listrec.QuoteLineItems}" var="Listrec2">
    {!Listrec2.QuoteId}
// I think my details records have to be here.
</apex:repeat>

All Answers

Shyam BhundiaShyam Bhundia
try doing 
<apex:repeat value="{!Listrec.QuoteLineItems}" var="Listrec2">
    {!Listrec2.QuoteId}
// I think my details records have to be here.
</apex:repeat>

This was selected as the best answer
RICARDO PALMARICARDO PALMA
Thank you so much Shyam!!!
It Works!!!!
You have a great day!!!!