Similar to this question, I'd like to be able to fire off a query (from an external application) to determine when someone is removed from a Salesforce Campaign. The question I linked has a good solution for determining when a campaign is modified (provided by a user) like so:

  (SELECT CampaignId FROM CampaignMember WHERE CreatedDate = TODAY)

Using similar logic (and assuming I can't just view these things in Salesforce itself), how can I determine if someone is removed from a campaign? There doesn't seem to be a CampaignMember field available for that.


This is a textbook use case for Change Data Capture, which supports CampaignMember.

Your remote application would subscribe to Change Data Capture events for the CampaignMember object and could then consume events where those records are deleted. You wouldn't need to run any queries, which would be a dicey approach anyway since anything that was hard deleted wouldn't be available under any circumstances.

An alternate approach would be to use the Sobject Get Deleted API endpoint, which will allow you to poll for information about deleted records in any sObject.

  • This all seems very useful. However, I'm curious- is there no field that will return to me when/if a Campaign has someone removed from it? Like a ModifiedDate that changes when a CampaignMember is removed? I have very limited access to this client's Salesforce instance, so I'm trying to figure out how to do as much of this work externally as I can. – questionable_code May 29 '20 at 16:49
  • 1
    You may be able to scrape information from the roll-up fields and LastModifiedDate on the parent Campaign, but it's not going to provide you with the granularity that it sounds like you need. – David Reed May 29 '20 at 18:04
  • That definitely sounds like a good place to look. The specific project I'm working on is a two-way integration between our application and a customer's Salesforce instance, where I'm trying to detect when people are added/removed from a Salesforce Campaign in order to be able to determine when to add/remove those Contacts from our distribution lists. I was thinking it would be a little easier to determine when those movements happened, but it seems like it might take a little more doing from the Salesforce side. – questionable_code May 29 '20 at 18:12
  • 1
    I really think you need to poll the SObject Get Deleted endpoint if you don't want to use Change Data Capture. If a Campaign is large, resyncing the whole Campaign every time it changes is going to be very inefficient. – David Reed May 29 '20 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.