When Business Hours is enabled in Case Flags, a scheduled Apex job is created in the background that runs periodically. Scheduled Apex runs under the Salesforce user that created the job, which is the user that enabled Business Hours in Case Flags Setup.
The purpose of the job (in the main Case Flags package) is to calculate the value of FLAGS__PreviousBusinessHours__c with the amount of business hours that have lapsed prior to the current day. Because of Salesforce platform limitations, this needs to be done as a scheduled job and can't be computed in real time. This job will include all cases which are currently flagged (Case Flag Date/Time <> NULL), and is used to help the next day of flag aging pick up where it left off.
For those who have installed the Case Flags Metrics Extension, this job will update the value FLAGS_METRICS__Business_Hours_Elapsed_Previous__c of all open cases which have been enabled for Case Flags (regardless if the case is currently flagged).
- For those with the Metrics Extension installed and Organization-Wide enabled, this will apply to all open cases.
- For those with the Metrics Extension installed and Organization-Wide disabled, this will apply to all open cases where the Enable Case Flags checkbox field is populated.
When this job runs at the end of Business Hours, the Last Modified Date/Time and Last Modified By ID (User) are updated with the date/time the Apex job ran and the User the job ran under, respectively. Last Modified fields are "System Audit Fields" and changes to them can't be avoided.
Important: If you use the Last Modified Date/Time field to monitor activity on Cases, consider creating a custom date/time field and using workflow to update it when specific actions occur.
If you would like the job to run under a different user such as a dedicated API user, log in as that user, disable Business Hours in Case Flags Setup, and re-enable it.
If Case Flags is not used for all cases in your organization, you can limit the "scope" of the business hours Apex batch job.
For more information, please review our documentation on Configuring Selective Processing here.