0

I'd like to pull all Opportunity IDs that have a task associated with a certain person.

I've tried the following

Select ID from Opportunity where AccountID IN (Select AccountID From TASK WHERE CreatedBy.Name='Person' OR LastModifiedBy.Name='Person' )

But I get the following error ERROR at Row:1:Column:80 Entity 'TASK' is not supported for semi join inner selects"

Is there any work around to this?

Chris
  • 5,444
  • 16
  • 63
  • 119

1 Answers1

0

In just SOQL, I'm not sure if there is a way to do it. But if you're doing this as part of a trigger/class, you can do something like this:

List<Id> accountIds;
List<Task> tasks = [Select AccountID From TASK WHERE AccountId != null AND (CreatedBy.Name='Person' OR LastModifiedBy.Name='Person')];
for(Task task : tasks) {
    accountIds.add(task.AccountId);
}
List<Opportunity> opportunities = [Select ID from Opportunity where AccountID IN :accountIds];
jongpie
  • 101
  • 1