I'm trying to make an SOQL query to the CampaignMember table, which checks both the Campaign of the CampaignMember and the ParentCampaign of that CampaignMember.

The Campaign.ParentId works, but the Campaign.ParentCampaign doesn't, telling me it doesn't exist, despite it being in the list of available fields on the Campaign object.

My SOQL query looks like this:

SELECT Contact.Account.MauticID__c, Campaign.MtcSID__c, Campaign.ParentId, Campaign.ParentCampaign FROM CampaignMember WHERE (CampaignId IN :cids OR (Campaign.ParentId IN :cids AND Campaign.ParentCampaign.MtcSID__c != NULL)) AND Contact.Account.MauticID__c != NULL AND Contact.Account.MtcPossibleSpamsniffer__c = FALSE AND Contact.Account.NoEmails__c = FALSE AND MtcInMautic__c = FALSE

which gives the error "No such column 'ParentCampaign' on entity 'Campaign'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names."

I've also tried Campaign.Parent (as that is the field's name according to the Salesforce setup page), but that gives the same error.

1 Answer 1


You can't query relationships. You can either query Id or fields from relationship.

Try to use

SELECT Campaign.ParentId FROM CampaignMember 


SELECT Campaign.Parent.Id FROM CampaignMember 


 SELECT Campaign.Parent.<StandardOrCustomFieldName> FROM CampaignMember 
  • D'oh! I actually realized the mistake almost immediately after posting. Thanks, it works fine now! (But I'm still a little confused as to why the documentation refers to the reference field as ParentCampaign. Maybe it's outdated. Commented May 8, 2019 at 11:54
  • 1
    The documentation describe SOAP API which might have different signature or names than the standard Apex SOQL.
    – Patlatus
    Commented May 8, 2019 at 11:55
  • Ah... But where is the documentation for the Apex-available fields for the Campaign object then? I've been searching around but couldn't find it anywhere Commented May 8, 2019 at 11:57
  • Object Reference for Salesforce and Lightning Platform seems to copy information from SOAP API Guide developer.salesforce.com/docs/atlas.en-us.object_reference.meta/…, we should report somewhere that Object Reference for Salesforce and Lightning Platform is incorrect. There is no such relation name as ParentCampaign, it is just Parent.
    – Patlatus
    Commented May 8, 2019 at 12:03
  • 1
    I have reported using Feedback bottom link. Not sure if they would change the documentation though
    – Patlatus
    Commented May 8, 2019 at 12:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .