Skip to main content
3 of 3
deleted 1 character in body
Benj
  • 11.3k
  • 9
  • 67
  • 121

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