Workflow is one of the most powerful tools available in Salesforce. It helps to automate various business processes. Workflow allows you to Update a filed, Create a task, send an Email-Alert and Outbound message based on some criteria. In Salesforce workflow actions are of two types

  • Immediate Action: Immediate actions execute, the moment when the criteria is met.
  • Time-Dependent Action: Time-Dependent actions execute at a specific time defined by you, such as sending an Email alert after 24 hours of lead creation if the lead is not contacted. When the specified time passes, workflow rule re-evaluates to check that record still meets the rule criteria.

Steps to configure time-based workflows within Salesforce

In this article, we are going to see Time-Dependent action for workflow. The requirement is that an email alert should be sent to opportunity owner, 15 days before the opportunity closing date. Let’s create a time-based workflow for above requirement. Following are the steps to be followed to meet the above requirement.

  1. Creating an Email Template.
  2. Creating an Email Alert.
  3. Creating a Workflow.

Step 1: Creating an Email Template

Below are the steps to Create Email Template

  • Navigate to Setup->Communication Templates->Classic Email Templates

Navigate to Setup of classic Email Templates

  • Click on “New Template” button. Below screen will be shown

Click on New Template button

  • Choose the type of the template you would like to create. Here I’m selecting “Text” email template.
  • Click on “Next” button. You will be redirected to the following page.

Screenshot of text email template

  • Select Folder as “My Personal Email Templates” if you want the Email template available only for your account. If you want to make it available for all users in your company then select “Unified Public Email Templates”.
  • Select the “Available for Use” Check box to make it available for use.
  • Enter the Template Name.
  • Select your time zone.
  • Enter the description, subject and Email Body for your Email Template as shown below.

Enter the description in email template

  • Email body contains the content that you want to send as an alert. Salesforce also provides you merged fields to use in the Email body. In the above figure {!Opportunity.OwnerFullName}, {!Opportunity.Name}, {!Opportunity.CloseDate} and {!Opportunity.Link}” are the merged fields used in the body to get opportunity owner’s name, opportunity Name, Opportunity closing date and Opportunity record link. You can get this merged fields in “Available Merge Fields” section as shown in below figure.
  • Select the “Field type”. I’ve selected “Opportunity Fields”.
  • Select the field you want to use from the dropdown list. I’ve selected “Opportunity Name”.
  • Copy the merge field value and use in the “Email Body”.

Screenshot of Select the Field type

  • Click on “Save” button. The template is ready to use. Now we’ll create Email Alert for this template.

Step 2: Creating an Email Alert

Below are the steps to create Email Alert

  • Navigate to Setup->Build->Create->Workflow & Approvals-> Email Alerts
  • Click on “New Email Alert” button. You will be redirected to the following page.

Screenshot of Creating an Email Alert

  • Enter all the required fields.
  • Select Object from the drop-down list. As we are creating an alert for opportunity object I’ve selected “Opportunity” from the drop-down list.
  • Select the Email template from lookup field. I’ve selected Email Template created in
  • Select the recipient to whom you want to send an Email Alert. Our requirement is to send an Email alert to Opportunity owner. Select “Owner” from “Recipient Type” and add the recipient from “Available Recipients” to “Selected Recipients” as shown below.

Screenshot of Selected Recipients

  • Click on “Save” button. Now we’ll create a workflow with Time-Dependent action to trigger this Email alert.

Step 3: Creating a Workflow

Following are the steps to create a workflow

  • Navigate to setup->Build->Create->Workflow & Approvals->Workflow Rules.
  • Click on “New Rule” and select the Object as shown below. Here I’ve selected the “Opportunity” object.

Screenshot of navigate to workflow rules

  • Click on “Next” button.
  • Enter all the required fields as shown below.

Enter all the required fields

  • Select “created, and every time it’s edited to subsequently meet criteria” as Evaluation Criteria
  • I’ve selected “Opportunity stage not equals to Closed Won, Closed Lost” as Rule Criteria.
  • Click on “Save & next”. You will be redirected to the following page.

Screenshot of Adding Time Trigger

  • Click on “Add Time Trigger”. You will be redirected to the following page

Workflow time trigger edit

I’ve selected 15 days before opportunity close date to meet the above requirement. Click on save button. The following screen will be shown

Screenshot of Adding Workflow action

  • “Select Existing Action” from “Add Workflow Action” dropdown list. The following screen will be shown.

Screenshot of Selecting Existing actions

  • Choose “Action Type” as “Email Alert” and select the Email Alert created in step2 and click on “save”. You will be redirected to the following page.

Choosing Action Type as Email Alert

  • Click on “Done”. Below screen will be shown.

Activating the workflow

  • Click on “Activate” button to activate the workflow.

We have successfully configured Time Based Workflow. Now we will test the workflow by creating an opportunity which meets the criteria.

Successfully configured Time Based Workflow

  • When a workflow rule is triggered, all the Time-Dependent actions will be placed in the workflow queue.
  • You can check the queued time-based actions by navigating to Setup-> Monitor-> Time-Based Workflow. You can use the criteria to monitor the queue as shown in the below screenshot.

Screenshot of Time Based Workflow

  • As we have created a workflow for opportunity object, I’ve selected object as criteria. In the search result, a time-based action is queued to trigger email alert 15 days before the opportunity closing date.

Note:

  1. Time-Based workflow rules are not applied to previously created records. The rule is applied only for the records created/updated after the workflow is activated.
  2. If a record that has pending actions is deleted, then all the pending actions for that record will be removed from the queue.

In this way, you can configure Time-based workflows. You can also add multiple time-dependent actions for a workflow rule to meet your business requirements.


How we can help

Our team can help you customize and integrated Salesforce as per your business process. Read about our Salesforce Integration Services. Reach out to us for a free assessment of your business needs.

Contact us for a free assessment