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

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

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....!