Skip to content
Suggest a correction

Check that the Account Team includes every open Opportunity owner

Example4 min read

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.

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.

  • 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.

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.

FieldValue
LabelAccount Record Alignment
ObjectAccount
Record Health Check Set NameAccount_Record_Alignment
ActiveCleared until validation succeeds
Card TitleAccount Record Alignment
Card SubtitleConfirm that related records agree before forecast review.
When Checks RunWhen the user clicks Run
Found/Expected DisplayShow on demand

Open Setup → Custom Metadata Types, select Manage Records next to Record Health Check, select New, enter these values, and save.

FieldValue
LabelAccount Team Covers Opportunity Owners
Check SetAccount Record Alignment
Evaluation TypeCompare two queries
Record Health Check NameAccount_Team_Covers_Opportunity_Owners
Evaluation Order30
ActiveCleared until validation succeeds
Source QuerySELECT OwnerId FROM Opportunity WHERE AccountId = {!record.Id} AND IsClosed = false
Source Query FieldOwnerId
How To Read Query ResultsCompare as lists
Comparison OperatorLists contain all
Comparison QuerySELECT UserId FROM AccountTeamMember WHERE AccountId = {!record.Id}
Comparison Query FieldUserId
If Query Finds No RecordsFail
Check TitleAccount Team includes every open Opportunity owner
Check DescriptionPasses when every owner of an open Opportunity on the Account is an Account Team member.
Message When FailedSome open Opportunity owners on {!record.Name fallback="this Account"} are not on the Account Team.
Fix MessageAdd the missing owners to the Account Team, or reassign the Opportunities, following your process.
Message When Unable To EvaluateUnable to compare Opportunity owners with the Account Team. Confirm that you can see both.
Failure SeverityWarning
Action LabelReview Account Team
Action URL/lightning/r/Account/{!record.Id}/related/AccountTeamMembers/view
Applies ToAll 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 to 0.
  1. Run the Validate Record Health Check Configuration Flow action, as described in Validate configuration before activation, and correct every error.
  2. Activate the Check, then the Check Set.
  3. Add the Record Health Check component to the Account record page, select Account Record Alignment (Account_Record_Alignment), and activate the page.
  4. Assign Record Health Check Card User to the users who test the card.

In this table, A, B, and C are three different users. Select Run on the card for each case.

Owners of open OpportunitiesAccount Team membersResult on the card
NoneAnyWarning
ANoneWarning
AAPass
A, BAWarning
A, BA, B, CPass

Both lists include only records the running user can 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.

What you seeWhat to check
The Account Team related list does not openAccount Teams are enabled, and the related list is on the Account page layout.
An owner on the team still failsComparison Operator is Lists contain all, and Comparison Query Field is UserId.
Unable to CheckThe user can read Opportunities and Account Team members.