Road Block: Can’t Use Activities in the Dynamic Related List Component on Lightning Pages
Salesforce Lightning Experience offers powerful tools for admins and developers to customize user interfaces and improve productivity.
One such tool is the Dynamic Related List - Single component, which allows admins to display related records with powerful filters and sorting directly on a Lightning Record Page.
However, a common limitation encountered is that Salesforce Activities (Tasks and Events) cannot be used directly in the Dynamic Related List component.
This can be a challenge when you want to surface relevant activity data dynamically alongside other related records.
This article provides practical workarounds to help Salesforce administrators and developers overcome this limitation while maintaining an efficient and user-friendly Lightning page experience. Read on to discover alternative solutions for displaying Activities dynamically in Salesforce Lightning.
Understanding the Limitation: Why You Can't Use Activities in Dynamic Related Lists
Activities in Salesforce—Tasks and Events—are unique in that they are handled differently under the hood. Specifically:
Activities are polymorphic and tied to various objects through the WhoId (related to a Contact or Lead) and WhatId (related to an Account, Opportunity, or other objects).
Salesforce internally treats Activities differently from standard related lists, causing incompatibility with the Dynamic Related List component.
As a result, the Dynamic Related List component does not support Activities, and admins cannot use it to filter, sort, or display Tasks and Events dynamically on a Lightning page.
Given this built-in limitation, admins and developers must explore alternative methods to display Activities effectively.
Workaround 1: Use the Standard Related List Component for Activities
The simplest workaround is to use the standard Related List - Single component for Tasks and Events where you need to show Activities on a record page.
The standard related list supports displaying Tasks and Events with basic filtering options.
While not as flexible or dynamic as the new Dynamic Related List component, it ensures that users can still see Activities associated with the record.
Place separate “Tasks” and “Events” related list components on the page if needed.
Advantages:
Easy to implement without custom development.
Supports standard user functionality such as creating and editing Activities.
Disadvantages:
Lacks advanced filtering or dynamic visibility controls available in the Dynamic Related List.
Clutters the page with multiple related lists if showing Tasks and Events separately.
Workaround 2: Create Custom Lightning Components using Lightning Web Components (LWC)
For organizations requiring greater control and dynamic filtering on Activities, building a custom Lightning Web Component (LWC) is the ideal approach.
Use Salesforce Apex to query Activities associated with the current record dynamically.
Implement flexible filtering, sorting, and grouping in the LWC to mimic or exceed Dynamic Related List functionality.
Display Tasks and Events in a combined or separate list with custom UI tailored to your use case.
Implementation Tips:
Use SOQL queries filtering by WhoId or WhatId depending on your object context.
Paginate results and cache queries for performance optimization.
Leverage LDS (Lightning Data Service) and Apex controllers securely.
Advantages:
Full control of UI, including custom filters, sorting, and display options.
Ability to combine Tasks and Events or separate them as needed.
Consistent look and feel with Lightning Experience.
Disadvantages:
Requires development effort and maintenance.
Needs testing and deployment lifecycle before production use.
Workaround 3: Use Salesforce Reports and Report Chart Components
Another workaround is embedding Activity-related Salesforce Reports using the Report Chart component or other AppExchange tools.
Create a report that filters and groups Activities relevant to the record, perhaps grouped by status, date, or priority.
Add this report as a chart or table on the Lightning page using the Report Chart standard component.
Set the filter on the report to dynamically match the record's ID (using the “Filter Logic: equals to” feature).
Advantages:
No code required, leverages powerful Salesforce reporting engine.
Real-time visibility of activity data with sorting and grouping.
Easy to update reports and filters without re-deploying components.
Disadvantages:
Report charts have limited interactivity compared to list views.
Not as seamless as a native related list for direct editing of Activities.
Workaround 4: Leverage Salesforce Flow and Custom Actions
Salesforce Flow can be used to create custom list views or overlays showing Activities related to a record.
Build a Flow that retrieves and presents Tasks and Events filtered by object's ID.
Embed the Flow on the Lightning page with the Flow component.
Add buttons to launch standard or custom actions to create or edit Activities inline.
Advantages:
No complex code required; declarative build.
Supports guided process for users managing Activities.
Canrs managing Activities.
Written w help of ai