You need to sign in to do that
Don't have an account?
John L Schneider II
I am trying to get a list of Accounts who have contacts that are members of a campaign (ID is in code) but don't have a contact that is a member of the same campaign with a contact.textfield (Client_Options__c) set to 'Kick Me'.
I'm running in to the "The inner and outer selects should not be on the same object type" error and can't figure out a way around this. This is a query that is run on demand so either a revised query or something I could drop in to Execute Anonymouse would be fantastic! I appreciate any guidance here!
Accounts with Campaign Members
SELECT Contact.AccountId FROM CampaignMembers WHERE Contact.AccountId NOT IN (SELECT Contact.AccountId FROM CampaignMember WHERE CampaignId = '7011A00000142mwQAA' AND Contact.Client_Options__c = 'Kick Me') AND Contact.AccountId IN (Select Contact.AccountId FROM Contact WHERE Id IN (Select ContactId FROM CampaignMember WHERE CampaignId = '7011A00000142mwQAA') ORDER BY Owner.Name ASC
I am trying to get a list of Accounts who have contacts that are members of a campaign (ID is in code) but don't have a contact that is a member of the same campaign with a contact.textfield (Client_Options__c) set to 'Kick Me'.
I'm running in to the "The inner and outer selects should not be on the same object type" error and can't figure out a way around this. This is a query that is run on demand so either a revised query or something I could drop in to Execute Anonymouse would be fantastic! I appreciate any guidance here!
Since Salesforce doesn't allow you to execute inner selects on the same object type you will need to get that set out of the query: In the other hand, If you need to keep only one query, you can get the list of account form with two simple for loops: Hope this helps you.
Regards
All Answers
Since Salesforce doesn't allow you to execute inner selects on the same object type you will need to get that set out of the query: In the other hand, If you need to keep only one query, you can get the list of account form with two simple for loops: Hope this helps you.
Regards