You need to sign in to do that
Don't have an account?
Combine SOQL Query
There must be a way to do this easier than I am right now:
SELECT id , who.id, ActivityDateTime FROM event WHERE Subject like '%goto_%
Then I iterate though the results and perform the next query.
SELECT id, FirstName, LastName, LastActivityDate FROM Lead WHERE DemoAttendee__c = False
Must be a way to make it into a single query. The 2nd one is only valid for about 30% of the returned items from the first query and it makes it very inefficient.
By the way, I have no need for any of the data in the first query. I just need the Lead object returned--it has everything I want.
Thank you for that. My mistake, I dumbed down the query for the purpose of this post. I'm feeding WhoId from the Event to get the Lead object in the 2nd query.
In normal SQL I'd write something like this:
SELECT * FROM Lead WHERE Id IN (SELECT Who.Id FROM Event WHERE Subject like '%goto_%) and DemoAttendee__c = False
That would return the information I need. But I can't seem to link Event's and Lead like that.
And the Event object doesn't allow me to sub-select the referenced Who object, otherwise I could write something like this:
SELECT <whatever> FROM Event WHERE Subject LIKE '%goto_%' AND Who.DemoAttendee__c = False