+ Start a Discussion
Ankit Kalsara 6Ankit Kalsara 6 

how to perform time trigger action using apex trigger?

Hi team,

I have workflow rule which sends email notification once the criteria is met and sends another notification 30days after the rule trigger date.

I am replacing the entire workflow rule using apex trigger. How do I send email notification 30days after the initial rule trigger date? How can I perform time trigger actions of workflow rule using basic apex trigger?
AbhishekAbhishek (Salesforce Developers) 
A setting that defines when time-dependent workflow actions should fire. When creating time-dependent actions and time triggers for workflow rules, consider the following :

When defining a time trigger, use standard and custom date and date/time fields defined for the object. Specify the 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.

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.
Apex triggers that fire as a result of time-dependent actions may get executed in a single batch or independently. Follow these best practices:
In case they fire independently–Ensure that your Apex logic is scoped for a single scheduled action. For example, don't use Apex static variables to communicate state across Apex code triggered by different scheduled actions.
In case they fire in a single batch–Be aware of how the combination of your time-dependent actions and Apex triggers impact your Apex governor limits.
Salesforce evaluates a 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.


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.
You can't archive a product or price book that has pending 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 are set to Evaluate the rule when a record is: created, and every time it’s edited.

The workflow rule is included in a package.

For the code suggestions try the below developer blog,


I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.