+ Start a Discussion
debradebra 

How to process SOQL results in Apex for query that returns parent data and child object list

I want to retrieve some fields from the Quote object and the list of  child QuoteLineItems. 
I have a dyanmic SOQL query (field list for QuoteLineItems is dynamic).  The query runs fine but in viewing the debug output  the returned values do not seem to include the QuoteLineitems. 

Here is an example of my dynamic SOQL query.
I want to process thru the list using the OpportunityId and the QuoteLineItems for each record returned as inputs to another method.

select opportunityId, ( SELECT QuoeID,  PricebookEntryId,  discount, unitprice from QuoteLineItems ) from Quote where Id IN ('0Q0c000000020MUCAY')

Perhaps I'm trying to do too much in one query ;-)

kevin Carotherskevin Carothers
Can you post the query?
Satya MSatya M
@zendebra 

Try the below code  :

Quote quoteData = [select opportunityId, ( SELECT QuoeID,  PricebookEntryId,  discount, unitprice from QuoteLineItems ) from Quote where Id IN ('0Q0c000000020MUCAY')];

system.debug(quoteData); -------> which gives you quote values.

list<QuoteLineItems> quoteLineItemData =  quoteData.QuoteLineItems;

system.debug(quoteLineItemData); ----> wich gives you quote related quotelineitems.


Hope it helps you....!

Thanks
Satya.