Considerations for Time-Dependent Actions and Time Triggers | Salesforce
Considerations for Time-Dependent Actions and Time Triggers
Available in: Lightning Experience and Salesforce Classic
Available in: Professional, Enterprise, Performance, Unlimited, and Developer Editions
When creating time-dependent actions and time triggers for workflow rules, consider the following.
Defining Time Triggers
When defining a time trigger, use standard and custom date and date/time fields defined for the object. Specify time using days and hours. The valid range is 0 to 999 days or hours.
You can modify existing time triggers by adding or removing actions.
Removing all the actions from a time trigger does not remove the trigger. Empty triggers are still queued and count against your hourly workflow time trigger limit. To remove scheduled time triggers, delete them from the workflow queue.
Time Trigger Processing
Time-dependent actions aren’t executed independently. They’re grouped into a single batch that starts executing within one hour after the first action enters the batch. Therefore, any Apex triggers that fire as a result of those grouped actions are also executed in a single batch. This behavior can cause you to exceed your Apex governor limits if you design your time-based workflow in conjunction with Apex triggers.
Salesforce evaluates time-based workflow on the organization’s time zone, not the user’s. Users in different time zones might see differences in behavior.
Salesforce doesn’t necessarily execute time triggers in the order they appear on the workflow rule detail page. Workflow rules list time triggers that use the Before field first, followed by time triggers that use the After field.
Salesforce doesn't display time-dependent action controls on the workflow rule edit page if you set the workflow rule evaluation criteria to Evaluate the rule when a record is:created, and any time it’s edited to subsequently meet criteria.
If you change a date field that is referenced by an unfired time trigger in a workflow rule that has been evaluated, Salesforce recalculates the unfired time triggers associated with the rule. For example, if a workflow rule is scheduled to alert the opportunity owner 7 days before the opportunity close date and the close date is set to 2/20/2011, Salesforce sends the alert on 2/13/2011. If the close date is updated to 2/10/2011 and the time trigger hasn't fired, Salesforce reschedules the alert for 2/3/2011. If Salesforce recalculates the time triggers to a date in the past, Salesforce triggers the associated actions shortly after you save the record.
If a workflow rule has a time trigger set for a time in the past, Salesforce queues the associated time-dependent actions to start executing within one hour. For example, if a workflow rule on opportunities is configured to update a field 7 days before the close date, and you create an opportunity record with the close date set to today, Salesforce starts to process the field update within an hour after you create the opportunity.
Time-dependent actions remain in the workflow queue only as long as the workflow rule criteria are still valid. If a record no longer matches the rule criteria, Salesforce removes the time-dependent actions queued for that record.
For example, an opportunity workflow rule can specify:
A criteria set to “Opportunity: Status not equals to Closed Won, Closed Lost”
An associated time-dependent action with a time trigger set to 7 days before the opportunity close date
If a record that matches the criteria is created on July 1 and the Close Date is set to July 30, the time-dependent action is scheduled for July 23. However, if the opportunity is set to “Closed Won” or “Closed Lost” before July 23, the time-dependent action is removed from the queue.
Salesforce ignores time triggers that reference null fields.
Time-dependent actions can automatically be queued again if the record is updated and the evaluation criteria is set to Evaluate the rule when a record is:created, and any time it’s edited to subsequently meet criteria. Using the previous example, if the opportunity status is changed from Closed Lost to Prospecting and the workflow rule evaluation criteria is Evaluate the rule when a record is:created, and any time it’s edited to subsequently meet criteria, Salesforce reevaluates the time triggers and adds the appropriate actions to the workflow queue.
Deleting a record that has pending actions removes the pending actions from the workflow queue. You can't restore the actions, even if you undelete the record.
If the evaluation criteria is set to Evaluate the rule when a record is:created, the workflow rule evaluates its time triggers only once. If the record that fired the rule changes to no longer meet the evaluation criteria, Salesforce removes the pending actions from the queue and never reapplies the rule to the record.
You can deactivate a workflow rule at any time. If the rule has pending actions in the workflow queue, editing the record that triggered the rule removes the pending actions from the queue. If you don't edit the record, the pending actions are processed even though the rule has been deactivated.
Time-dependent actions aren't executed for a reevaluated workflow rule in the following situations:
The reevaluated workflow rule’s immediate actions cause the record to no longer meet the workflow rule criteria.
An Apexafter trigger that is executed as a result of a workflow or approvals action causes the record to no longer meet the workflow rule criteria.
Configuring a task’s Due Date to “Rule Trigger Date” sets time triggers and workflow task due dates based on the date that the workflow time trigger’s action is executed. For example, if the task due date is “Rule Trigger Date plus 10 days” and the time trigger is executed on January 1, Salesforce sets the task due date to January 11.
You can add a new active workflow rule with time triggers in a change set and deploy it. You can only change time triggers on a workflow rule in a change set if it's inactive. The rule must be activated in the destination organization manually or through another change set that only activates workflow rules and makes no time trigger changes.
For example, let’s say you have an inactive workflow rule in your destination organization, and your change set contains an active workflow rule with the same name and new or different time triggers. The deployment fails because it activates the workflow rule first and then tries to add or remove the time triggers.
You must add time-dependent actions manually when including a workflow rule in a change set. The View/Add Dependencies function doesn’t detect time-dependent actions.
Using Time-Dependent Workflow with Leads
You can’t convert a lead that has pending actions.
If Validation and Triggers from Lead Convert is enabled, existing time-based workflow actions on leads aren't triggered during lead conversion.
If a campaign member based on a lead is converted before the completion of the time-based workflow actions associated with it, Salesforce still performs the time-based workflow actions.
Time triggers don’t support minutes or seconds.
Time triggers can’t reference the following:
DATE or DATETIME fields containing automatically derived functions, such as TODAY or NOW.
Formula fields that include related-object merge fields.
Salesforce limits the number of time triggers an organization can execute per hour. If an organization exceeds the limits for its Edition, Salesforce defers the execution of the additional time triggers to the next hour. For example, if an Unlimited Edition organization has 1,200 time triggers scheduled to execute between 4:00 PM and 5:00 PM, Salesforce processes 1,000 time triggers between 4:00 PM and 5:00 PM and the remaining 200 time triggers between 5:00 PM and 6:00 PM.
You can't archive a product or price book that has pending actions.
If time-based workflow actions exist in the queue, you can’t add or remove time triggers or edit trigger dates without deleting the actions first. Because the deleted records can’t be restored, carefully consider the implications of editing the workflow rules before you proceed. If you decide to edit the workflow rules, deactivate the workflow that you want to edit, edit the rules as needed, and then save your changes. For information about finding and deleting time-based workflow actions in the queue, see Monitor Pending Workflow Actions.
You also can’t add or remove time triggers if:
The workflow rule is active.
The workflow rule is deactivated, but has pending actions in the queue.
The workflow rule evaluation criteria is set to Evaluate the rule when a record is:created, and every time it’s edited.