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
guest1231231guest1231231 

Get Id Value From Subquery

How do you get the Opportunity Id from this query?

 

 

accts = [select Id, (select Id from Opportunities) from Account

 

-Thanks

 

VinOKVinOK

here's a code fragment that will pull out that Opportunity Id from your query

 

 

List<Account> acctList = [select Id, (select Id from Opportunities) from Account where id=:myAccountId];
		
List<Opportunity> optyList = acctList.get(0).Opportunities;
		
String myOptyId = optyList.get(0).id;