function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Oliver MexnerOliver Mexner 

Erroneous record changes

Hi Developer Forum,
I am trying to understand why some records in our Salesforce Sales instance are changed automatically each night. I have set up User Trace Flags in the Debug Logs, I see  'Batch APEX' all over the logs, don't know what that means, I am not a developer.
I would appreciate your support as the Salesforce support team says this is not part of their responsibility.
Thanks in advance!
SwethaSwetha (Salesforce Developers) 
Hi Oliver,
The batch apex here indicates that there is a batch class code written in your org that runs to execute logic of updating records.

See more about what a batch class is : https://trailhead.salesforce.com/content/learn/modules/asynchronous_apex/async_apex_batch

To run this batch class, there should be a scheduler class (https://help.salesforce.com/s/articleView?id=sf.code_schedule_batch_apex.htm&type=5) written via code or setup via UI (Administration Setup->Monitoring->Scheduled Jobs )

At this scheduled time, the batch class is running the records and updating the records automatically.

If this information helps, please mark the answer as best. Thank you
Oliver MexnerOliver Mexner
Hi Swetha,
Thank you very much for your quick reply.
I have found the scheduler ("Activity Commander Batch, type=Scheduled Apex). How can I drill down to find out what this is actually doing?
SwethaSwetha (Salesforce Developers) 
Can you please check if there is an apex class named "Activity Commander Batch"  in your org. To be able to find what it is doing, we should review the code logic.

Thanks
Oliver MexnerOliver Mexner
I'm looking under "Apex Classes" and see "ActivityMonitorBatch", but not "Activity Commander Batch". Is that what we're looking for?
Ashish  VermaAshish Verma
Hi Oliver, is it possible for you to paste a snippet of that class here?

Also mention which object records are being updated overnight? Thats how we can check that the batch class is processing those records and on based on what logic.

One more thing you can do, check the last modified datetime of those records. Those should be around same. Then check the apex jobs which have executed around the same time. Follow --> Setup --> Apex Jobs. By matching the date time of execution/ Submitted date of the jobs and last modifed time of records we can get an idea which batch class is processing those records.
Oliver MexnerOliver Mexner
Hi Ashish, Please see my responses below, thanks!
SwethaSwetha (Salesforce Developers) 
HI Oliver,
Looks like your comment got truncated. Can you please repost it?Thx
Oliver MexnerOliver Mexner
ActivityMonitorBatch screenshot
This is the screenshot of the ActivityMonitorBatch.

Also mention which object records are being updated overnight? Thats how we can check that the batch class is processing those records and on based on what logic.
Oliver: the objects I have noticed these erroneous updates on were ‘Contacts’, where custom date fields were updated.


One more thing you can do, check the last modified datetime of those records. Those should be around same. Then check the apex jobs which have executed around the same time. Follow --> Setup --> Apex Jobs. By matching the date time of execution/ Submitted date of the jobs and last modifed time of records we can get an idea which batch class is processing those records.
Oliver: the erroneous updates all have a time stamp of around 1:15am. Below is the excerpt from the debug log, but I can’t find an apex job scheduled to run around that time:
Debug Logs screenshot
Oliver MexnerOliver Mexner
Hi Swetha, Ashish,
Is this what you were looking for?
Thanks!
Oliver