Check that the Account Team includes every open Opportunity owner
Create a Record Health Check on an Account that compares the owners of its open Opportunities with its Account Team members, and passes only when every owner is on the team. The example uses the Compare two queries Evaluation Type with the Lists contain all operator.
Why two queries fit
Section titled “Why two queries fit”Both lists come from related records: Opportunity owners and Account Team members. Compare two queries returns both lists and tests whether the team list contains every owner, without code.
Before you start
Section titled “Before you start”- Install Record Health Check, and assign yourself Record Health Check Admin and the Salesforce Customize Application permission.
- Confirm that Account Teams are enabled in Setup → Account Teams, and that your process requires each Opportunity owner to be on the Account Team.
- Confirm that the people who will use the card can read Opportunities and Account Team members.
Step 1: Create or choose the Check Set
Section titled “Step 1: Create or choose the Check Set”You can add the Check to an Account Check Set you already have. To create one, open Setup → Custom Metadata Types, select Manage Records next to Record Health Check Set, select New, enter these values, and save. Leave other fields at their defaults.
| Field | Value |
|---|---|
| Label | Account Record Alignment |
| Object | Account |
| Record Health Check Set Name | Account_ |
| Active | Cleared until validation succeeds |
| Card Title | Account Record Alignment |
| Card Subtitle | Confirm that related records agree before forecast review. |
| When Checks Run | When the user clicks Run |
| Found/Expected Display | Show on demand |
Step 2: Create the Check
Section titled “Step 2: Create the Check”Open Setup → Custom Metadata Types, select Manage Records next to Record Health Check, select New, enter these values, and save.
| Field | Value |
|---|---|
| Label | Account Team Covers Opportunity Owners |
| Check Set | Account Record Alignment |
| Evaluation Type | Compare two queries |
| Record Health Check Name | Account_ |
| Evaluation Order | 30 |
| Active | Cleared until validation succeeds |
| Source Query | SELECT OwnerId FROM Opportunity WHERE AccountId = {!record. |
| Source Query Field | OwnerId |
| How To Read Query Results | Compare as lists |
| Comparison Operator | Lists contain all |
| Comparison Query | SELECT UserId FROM AccountTeamMember WHERE AccountId = {!record. |
| Comparison Query Field | UserId |
| If Query Finds No Records | Fail |
| Check Title | Account Team includes every open Opportunity owner |
| Check Description | Passes when every owner of an open Opportunity on the Account is an Account Team member. |
| Message When Failed | Some open Opportunity owners on {!record. |
| Fix Message | Add the missing owners to the Account Team, or reassign the Opportunities, following your process. |
| Message When Unable To Evaluate | Unable to compare Opportunity owners with the Account Team. |
| Failure Severity | Warning |
| Action Label | Review Account Team |
| Action URL | /lightning/r/Account/{!record. |
| Applies To | All records |
How the values work:
- Lists contain all passes when the Comparison list, the team, contains every value in the Source list, the owners. Extra team members do not matter.
- If Query Finds No Records set to Fail reports a failure when either list is empty. An
Account with no open Opportunities fails too; to skip those Accounts instead, set Applies To
to When a count query matches, with the count query
SELECT COUNT() FROM Opportunity WHERE AccountId = {!record.Id} AND IsClosed = false, Count Must Be set to Greater than, and Count Value set to0.
Step 3: Validate and activate
Section titled “Step 3: Validate and activate”- Run the Validate Record Health Check Configuration Flow action, as described in Validate configuration before activation, and correct every error.
- Activate the Check, then the Check Set.
- Add the Record Health Check component to the Account record page, select Account Record Alignment (Account_Record_Alignment), and activate the page.
- Assign Record Health Check Card User to the users who test the card.
Step 4: Test the Check
Section titled “Step 4: Test the Check”In this table, A, B, and C are three different users. Select Run on the card for each case.
| Owners of open Opportunities | Account Team members | Result on the card |
|---|---|---|
| None | Any | Warning |
| A | None | Warning |
| A | A | Pass |
| A, B | A | Warning |
| A, B | A, B, C | Pass |
Both lists include only records the running user can see.
What users see
Section titled “What users see”A failed row shows Warning, the message, the fix message, and a Review Account Team link. Found lists the owners’ user IDs, and Expected reads “to contain all of” followed by the team members’ user IDs. Because IDs are hard to read, consider setting the Check’s Show Found and Expected to Hide.
Resolve problems
Section titled “Resolve problems”| What you see | What to check |
|---|---|
| The Account Team related list does not open | Account Teams are enabled, and the related list is on the Account page layout. |
| An owner on the team still fails | Comparison Operator is Lists contain all, and Comparison Query Field is UserId. |
| Unable to Check | The user can read Opportunities and Account Team members. |