Two great ways to increase the adoption of your Salesforce solution are push notifications and automating recurring tasks. The Salesforce platform provides multiple ways to trigger scheduled functionality and bring the information to the user. This can be achieved in multiple ways in Salesforce. In this post, we will see different ways in which we can schedule the processing of information at a future date/time.
The simplest form of receiving processed information in future is through scheduled reports or dashboards.
Salesforce Flow is a declarative process automation tool. In a record-triggered flow, apart from other activities, you can add a scheduled path which will run on a specified scheduled date/time. One can base the scheduled date/time on when the record is created or updated or on a date field value in the record. Scheduled paths run in the system context, so they have permission to access and modify all data. You can also specify a batch size to do any intensive batch records processing as part of the scheduled path. E.g. If you need to update all the accounts of a particular type when their parent account is updated.
The scheduled paths can be used to make any updates on related records or perform any time-delayed action. Also, if you need to make any updates to one of the Setup objects, such as User, then you can use the scheduled path to avoid the Mixed DML Exception. The Mixed DML Exception occurs when a transaction attempts to perform DML operations on both setup (e.g. User) and non-setup objects (e.g. Account) within the same context.
A schedule-triggered flow starts at the specified time and frequency for a batch of records. With this feature, you can schedule an auto-launched flow to start at a specific time and set it to run once, daily, or weekly. You can also specify the object and a filter condition so that the set of entry records going into the flow is defined. You can monitor scheduled flows from the Scheduled Jobs page in Setup.
You can use schedule-triggered flow to set up a recurring job which performs some operations on an object of interest. E.g. a job that reviews all accounts daily and sends some notifications to qualifying accounts or a daily job that reviews all open opportunities and creates Tasks based on pre-set criteria. One limitation of schedule-triggered flow right now is that there is no option to change the default batch size of 200. If there are any situations where you need control over changing this batch size, you will need to use scheduled apex.
When the above declarative options are not suitable then you can go for a custom coding option using Scheduled Apex. To invoke Apex classes to run at specific times, first implement the Schedulable interface for the class, then specify the schedule using either the Schedule Apex page in the Salesforce user interface or the System.schedule method. The system.schedule method can be used to provide an expression used to represent the one-time or recurring date time the job is scheduled to run.
The scheduled apex can be used to perform operations similar to scheduled triggered flow. But because of using Apex, you have more control over custom operations. If the processing is to happen on a large number of records then you can call the System.scheduleBatch method to schedule a batch job. You also have control over the batch size when using scheduled batch apex.
Another legacy method of scheduling the processing of data is Time-Dependent Action in a workflow. This action is similar to the scheduled path in a record-triggered flow. This is a legacy functionality in Salesforce. Starting in Winter ’23, Salesforce will be blocking the creation of new workflow rules. You can still activate, deactivate, and edit any existing workflow rules. For any new similar scheduling requirements, use a scheduled path in a record-triggered flow.
Automating recurring workflows, especially those that have to happen on a set schedule, usually reduces administrative overhead for users. Push notifications, if done right, increase the value of the system to the user. Both of these go a long way in improving the adoption of Salesforce within your organization.