Play Games

Search This Blog

Thursday, April 28, 2022

Single SOQL query to query Opportunity and Opportunity line items together in salesforce - Salesforce Globe For You

Single SOQL query to query Opportunity and Opportunity line items together in salesforce - Salesforce Globe For You

Solution: Use the following SOQL query.

SELECT id,Name,(Select id,Name,Quantity from OpportunityLineItems) from Opportunity

Example: Run the following piece of code in developer console.

List<Opportunity> lstOpportunity = new List<Opportunity>();

lstOpportunity = [SELECT id,Name,(Select id,Name,Quantity from OpportunityLineItems) from Opportunity];

system.debug('List of Opportunities: '+lstOpportunity);

Output:



No comments:

Post a Comment