Skip to main content
1 of 3
javanoob
  • 9k
  • 15
  • 77
  • 143

How to get List of Opportunities with condition on OpportunityContactRole?

I would like to retrieve the list of Opportunities which have at least one OpportunityContactRole with role equal to test

Right now, I am doing the below query but it retrieves all the rows in the opportunity table..

[SELECT Id,(SELECT Id FROM OpportunityContactRoles WHERE Role = 'test') FROM Opportunity WHERE IsClosed = TRUE AND IsWon = TRUE)];

Is there any better alternative for this??

javanoob
  • 9k
  • 15
  • 77
  • 143