Tips for Working with Activity Fields in Formulas
Get tips for creating accurate activity formulas by distinguishing between tasks and events. Plus, find guidance on handling activity-specific fields and correctly referencing polymorphic relationships like Who and What.
Required Editions
| Available in: both Salesforce Classic and Lightning Experience |
| Available in: All Editions |
Formulas on Task and Event Page Layouts
You can add formula fields created on the Activity object to both task and event page layouts. However, formulas that reference fields exclusive to one activity type often show blank values or generic defaults when viewed on the other type's layout.
- Task-specific fields: Formulas referencing fields such as Status or Priority don’t show useful data on event page layouts.
- Event-specific fields: Formulas referencing fields such as DurationInMinutes, ShowAs, or IsAllDayEvent don’t show useful data on task page layouts.
To avoid confusion, use the IsTask merge field to create conditional formulas that handle both activity types appropriately. See the “Distinguishing Between Tasks and Events” section in this topic for details. Alternatively, you can create separate formula fields for specific use cases and add them only to the relevant task or event page layout.
Task and Event Identification
The IsTask field is the key to determining if an activity is a task or an event. It returns TRUE for records that are tasks and FALSE for events. Use this field in conditional formulas to create logic that works correctly for both activity types.
For example, this formula shows “This is a task” on a task record or “This is an event” on an event record.
IF( IsTask, "This is a task", "This is an event" )For another example, this formula dynamically shows a record's priority if it’s a task or its duration if it’s an event.
IF( IsTask,
"Priority: " & TEXT( Priority ),
"Duration: " & TEXT( DurationInMinutes ) & " minutes" )
Who and What References
Activities use two special fields, WhoID (Name) and WhatID (Related To), to connect to other records. These fields can point to many different types of records, such as contacts, leads, and accounts. Formulas act differently depending on the object that they reference.
- Who (WhoID): References people (leads and contacts). For example, use Who.FirstName to get the person’s first name.
-
What (WhatID): References business objects (accounts, opportunities, custom objects, and so forth). For example, use What.Name to get the record name.
Not all combinations are valid. For example, consider the situation where an activity is related to a lead (WhoID). The WhatID is typically blank because leads aren’t associated with accounts or opportunities in the same way contacts are.
Activity-Specific Fields and Data Types
Tasks and events use the same underlying Activity object, but they store data in different fields. Referencing a field that belongs to the wrong activity type—like asking for a task's duration—can result in errors or blank values.
- Date vs. Date/Time fields: ActivityDate on tasks is a Date field, while
ActivityDateTime on events is a Date/Time field. Avoid mixing these
fields in formulas without proper conversion functions.
- Tasks: Use ActivityDate to reference the due date.
- Events: Use StartDateTime and EndDateTime to reference event timing.
- Task-specific fields: These fields work only for tasks. If referenced in a formula on an
event page layout or record, they typically return blank values or errors.
- Status
- Priority
- IsClosed
- IsRecurrence
- TaskSubtype
- CallType
- Event-specific fields: These fields work only for events. If referenced in a formula on a
task page layout or record, they don’t calculate correctly.
- StartDateTime and EndDateTime
- DurationInMinutes
- IsAllDayEvent
- ShowAs
- IsReccurrence2
- Shared fields: Both tasks and events use these standard fields. You can safely reference
them in formulas for either activity type without needing conditional logic (like
IsTask).
- Subject
- Description
- OwnerId
- CreatedDate
- LastModifiedDate
Custom Activity Fields
Custom fields you create on activities are available for both tasks and events unless you use page layouts and record types to control visibility.
- If you create an activity custom field with a default value formula, the formula runs for
both tasks and events. Use
IsTaskto provide different defaults. For example:IF( IsTask, "Follow-up required", "Meeting scheduled" ) - To avoid errors, make sure activity formula fields that reference task-specific or
event-specific standard fields include error handling or conditional logic. For
example:
IF( IsTask, IF( ISPICKVAL( Priority, "High" ), "⚠ High Priority", "Standard" ), "Event - No Priority" )
Activity Dates and Times
For tasks, reference the due date by using the Date field named ActivityDate. For events, reference event timing with the Date/Time fields named StartDateTime and EndDateTime.
Salesforce automatically calculates event duration, but you can reference this value in formulas by using DurationInMinutes. Convert to hours with:
DurationInMinutes / 60To calculate overdue status for tasks, compare ActivityDate to today's date and check if the task is closed.
IF( AND( NOT( IsClosed ), ActivityDate < TODAY() ), "Overdue", "On Track" )Recurring Activities
Both tasks and events support recurrence, but they use different fields.
- Tasks use IsReccurrence (with related fields RecurrenceStartDate, RecurrenceEndDate, and so forth.)
-
Events use IsReccurrence2 (with related fields RecurrenceStartDateTime, RecurrenceEndDate, and so forth.)
Use IsTask to check the appropriate recurrence field.
IF( IsTask, IsRecurrence, IsRecurrence2 )Activity Status and Completion
Use IsClosed to determine if a task or event is complete. This boolean field works for both activity types.
Task Status values vary by organization and task type, but typically include values like Not Started, In Progress, and Completed. Use ISPICKVAL or CASE when referencing status.
CASE( TEXT( Status ),
"Completed", "✓ Done",
"In Progress", "→ Working",
"Not Started", "○ Pending",
"Unknown" )
Other Considerations
- Polymorphic field limitations: Formulas referencing Who or What details only work if the relationship exists on the target object. For example, Who.Account.Name retrieves the account name if the activity is related to a contact, but returns a blank value if related to a lead.
- Read-only restrictions: Formulas can reference read-only activity fields to calculate data, but they can’t set of modify read-only fields. See the Object Reference for the Salesforce Platform for specific field limitations.
- Workflow and campaign contexts: Activities related to campaigns, workflows, or processes can have other fields available. Check the field availability for your specific use case.

