Print this page

How to use Task Due Date and Event Start Date and End Date in Formulas, Workflow and Validation Rules

Knowledge Article Number 000232236
Description Please see below to better understand the ability to reference the Task Due Date and Event Start Date and End Date in formulas in Salesforce, as well as in workflows and validation rules.
Resolution This article will help on how to use Task Due Date, Event Start Date and Event End Date in formulas, workflow rules and validation rules. 
 
Below are following field name:
 
1) Date (ActivityDate): The Due Date fields on Tasks, and the Start Date on all-day Events.
2) Time (ActivityDateTime): The Start Date (and time) on Events with times.
3) Duration (DurationInMinutes): The duration of an Event, in minutes. Use this with ActivityDate or ActivityDateTime to calculate the end time.

Scenario 1:

If you want to create a validation rule on event start date to ensure that user enters only today’s date as a start date else record should not be saved.

Here is the process to create validation rule.
  1. Click Setup | Customize | Activities | Event Validation Rules.
    1. Click on New.
    2. Enter the rule name
    3. Insert below formula under section “Error Condition Formula”:
NOT(DATEVALUE(ActivityDateTime) = TODAY())
                    d. Enter the error message.
                    e. Select the error location.
                    f.  Ensure that Active checkbox is checked.
                    g.Click on Save.
                    h. Now the users will not be able to select future date as Start Date for any event.  

Scenario 2:

If you want to create a validation rule on event start and end date to ensure that user to enter today’s date only.
Here is the process to create validation rule.
  1. Click Setup | Customize | Activities | Event Validation Rules.
    1. Click on New.
    2. Enter the rule name.
    3. Insert below formula under section “Error Condition Formula”:
NOT(AND(DATEVALUE(ActivityDateTime) = TODAY(), ((DATEVALUE(ActivityDateTime)-(DurationInMinutes /1440)=today()))))
                    d. Enter the error message.
                    e. Select the error location.
                    f. Ensure that Active checkbox is checked.
                    g. Click on Save.
                    h. Now the users will not be able to select future date as Start Date and End Date for any event.

For more information:
https://developer.salesforce.com/blogs/developer-relations/2014/09/formulas-in-salesforce.html




promote demote