0

I'm trying to get to attributes about the associated campaign member record when querying Campaign Influence. Unfortunately there is no field such as CampaignMemberId that I can see on the object. Is there a way to get to both the Campaign Influence and the Campaign Member fields using SOQL?

My final goal is to write a filter to find CampaignInfluence records where the CampaignMember hasResponded is true. If there were a relationship, this is what I'd write:

SELECT Id FROM CampaignInfluence where CampaignMember.hasResponded = true

1 Answer 1

0

Based on the ERD of the Campaign related objects: enter image description here

I think we can get the campaign influence and the member attributes through the Campaign as their parent object:

SELECT Name,
  (
    SELECT Contact.Name 
    FROM CampaignMembers
  ),
  (
    SELECT Id
    FROM CampaignInfluences
  )
FROM Campaign 
WHERE Id IN (
   SELECT CampaignId 
   FROM CampaignInfluence
   WHERE field = 'some filter'
)
2
  • That doesn't give me a match of which campaign members belong to which campaign influence. I can match them by the ContactId and CampaignId, but I really want to do it using SOQL. Ultimately, I want to filter campaign influence by attributes of the corresponding campaign members. I'll update the question to make it clearer. Jul 1, 2020 at 3:33
  • I don't think it is possible to get the match records given there is no direct relationship between the two objects (in SOQL). Cmiiw. Jul 1, 2020 at 4:14

You must log in to answer this question.

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