We have an integration for data synchronization between Salesforce and our system.
But meanwhile, we run into a performance problem because we are querying a lot of "old" campaigns with uninteresting data.
The data of interest are custom objects (only modified or new), these custom objects are in a many to one relationship to the standard campaign object.

My idea would be to mark the campaign as "uninteresting" with the help of a custom field. If all the custom objects for a campaign haven't been modified since a certain amount of time or no new custom objects were added to that campaign, mark the campaign as "uninteresting.
What would be the best way to achieve this? Some sort of timer job?

I guess there are different approaches to achieve our goal every idea is highly appreciated.
Thanks in advance.

  • 2
    A bit more information please. Does the parent object have to be marked when one child object hasn't been modified or when all child objects haven't been modified? Commented Nov 23, 2016 at 14:58
  • @SanderdeJong Sorry I edited the question a bit. It is about all custom objects. Modified or new.
    – noBillSide
    Commented Nov 24, 2016 at 7:17

1 Answer 1


One approach is to have a Scheduled Batch Job - Schedule a batch class to run on a daily basis. Query all the campaigns and its child record who has the max Last modified date among the child records. Compare the last modified date with the date threshold that you have set

Date dateThreshold = Date.Today().addMonths(-6);

List<Campaign> campaignList = Select Id, Uninteresting__c,...(Select Id, LastModifiedDate from Child_Records__r order by LastModifiedDate Desc limit 1) from Campaign
for(Campaign c : campaignList){
        for(Child_Records__c childs : c.Child_Records__r){
            if(childs.LastModifiedDate < dateThreshold ){
                c.Uninteresting__c = true;
        c.Uninteresting__c = true;

update campaignList;

Once you have updated the campaigns, you can filter them in your external callout.

Select Id from Campaigns where Uninteresting__c  = false;

You must log in to answer this question.

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