Advanced Record Ownership Filtering in Salesforce
Salesforce providers powerful record filtering capabilities for list views and reports, along with the ability to combine multiple filters with AND/OR/NOT logic.
A special Filter By Owner condition, allows to filter for all records, records owned by the current user, or records owned by queues.
However, a key limitation of Filter By Owner is that it acts as a pre-filter — i.e. a filter applied up-front, only once, and before any other filters — making certain logical conditions impossible to implement (e.g. show my records, or records owned by a particular queue).
This limitation can pose challenges in scenarios that require more flexible filtering. For instance, one might need to select records that were:
- Created by the current user OR Owned by the current user,
- Created by the current user OR Owned by a queue,
- Created by the current user AND Owned the user’s department queue.
These scenarios are especially common for objects that are “worked on” such as tasks, cases, orders, jeopardies, alarms, etc.
This post describes how to remedy Salesforce built-in ownership filtering limitations with custom formula filtering fields that can be used in filter conditions.
Adding Ownership Filtering Formula Fields
Fortunately, Salesforce filtering limitations can be overcome by adding a few custom formula fields, as described below. These (or similar) fields are included in our own products for tasks, orders, work orders, alarms, upgrade opportunities and a few other objects.
These formulas can be re-created on any Salesforce org using Setup → Object Manager → <Your Object> → Fields & Relationships → New → Formula:
Owned By Creator
True (checked) if a record is owned by the user who created it:
Owner.User.Id == CreatedBy.Id
This is useful to build filters such as Created by me or Owned by me.
Owned By Me
True (checked) if a record is owned by the current user:
Owner:User.Id == $User.Id
This is an equivalent of My Records pre-filter but can be used in conditions such as Created by me or Owned by me.
Queue Owner
True (checked) if a record is owned by a queue:
Owner:Queue.Id != NULL
This formula is useful when creating list views with active items that have not been assigned to individual users yet.
Created By Me
True (checked) if a record has been created (but not necessarily owned) by the current user:
Owner.User.Id == CreatedBy.Id
This formula is useful to managers who are interested in work progress of items that they created, regardless their current owner.
Owner Full Name
Object owner full name (‘John Doe’) or queue name (‘Engineering’) is a user-friendly replacement for the standard Salesforce owner alias:
IF(Owner:Queue.Id != NULL, Owner:Queue.QueueName, Owner:User.FirstName & ' ' & Owner:User.LastName)
This formula can also be created as a hyperlink for easier navigation.
Inactive Owner
Checked if the task is owned by a user (not a queue) and the user is disabled.
IF(Owner:Queue.Id != NULL, false, !Owner:User.IsActive)
This helps to filter tasks that are owned by inactive users, so they can be easily re-assigned.
Conclusions
Salesforce provides basic record ownership filtering mechanisms for list views and reports. However, because these filters function as pre-filters, they can limit the implementation of certain complex filtering conditions.
However, these limitations can be overcome with custom filtering formulas that can be used in conjunction with AND/OR/NOT filtering logic.
Nextian has extensive experience in implementing complex Salesforce customizations with Apex and Lightning helping our clients unlock the full potential of their Salesforce.
Contact us today to find out how we can help you!