Check open Opportunities for combined risks
Create a Record Health Check on an Account that fails when any open Opportunity has all three of these
warning signs at once: no activity in the last 30 days, no Next Step, and a Close Date outside
the current calendar quarter. The example uses the Verify with Apex Evaluation Type with a custom
Apex class, AccountOpenOpportunityHealthCheck, that a developer creates and deploys.
This Apex class does not install with Record Health Check. A developer must create, test, and deploy it from Open Opportunity health: Apex implementation before you configure the Check. Without the class, the Check shows Unable to Check.
Why Apex fits
Section titled “Why Apex fits”The rule needs all three warning signs on the same Opportunity. Three separate query Checks would each fail on different Opportunities, and a single query cannot easily express “outside the current quarter” together with the other conditions. A short Apex class can test each Opportunity and return one result for the Account.
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 the
AccountOpenOpportunityHealthCheckclass is deployed in the org: in Setup, open Apex Classes and find it. - Agree on the stale-activity window. This example uses 30 days. The class uses calendar quarters, not custom fiscal periods.
- Confirm that the people who will use the card can read Opportunities and their Last Activity, Next Step, and Close Date fields.
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 Apex Readiness |
| Object | Account |
| Record Health Check Set Name | Account_ |
| Active | Cleared until validation succeeds |
| Card Title | Account Readiness |
| Card Subtitle | Confirm recent engagement and pipeline readiness. |
| 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 | Open Opportunities Are Healthy |
| Check Set | Account Apex Readiness |
| Evaluation Type | Verify with Apex |
| Record Health Check Name | Open_ |
| Evaluation Order | 20 |
| Active | Cleared until validation succeeds |
| Apex Class | AccountOpenOpportunityHealthCheck |
| Apex Parameters (JSON) | {"staleDays": 30} |
| Check Title | No open Opportunity has all three risk signs |
| Check Description | Fails when an open Opportunity has no activity in 30 days, no Next Step, and a Close Date outside this quarter, all at once. |
| Message When Failed | Open Opportunities on {!record. |
| Fix Message | For each affected Opportunity, log current activity, enter a Next Step, or correct the Close Date. |
| Message When Unable To Evaluate | Unable to check open Opportunities. |
| Failure Severity | Critical |
| Action Label | Review open Opportunities |
| Action URL | /lightning/r/Account/{!record. |
| Applies To | When a count query matches |
| Applies When (Count Query) | SELECT COUNT() FROM Opportunity WHERE AccountId = {!record. |
| Count Must Be | Greater than |
| Count Value | 0 |
| Message When Not Applicable | {!record. |
How the values work:
staleDayssets how many days without activity make an Opportunity stale. The class accepts 1 to 3,650. A missing or out-of-range value silently uses 30, so always enter the value you intend.- The class returns the number of Opportunities with all three signs as Found, and 0 as Expected.
- Applies To skips Accounts with no open Opportunities before the class runs.
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 Apex Readiness (Account_Apex_Readiness), 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”Last Activity on an Opportunity comes from its completed activities, so create dated Tasks or Events to set it. Select Run on the card for each case.
| Open Opportunities on the Account | Result on the card |
|---|---|
| None | Skipped |
| One with all three signs | Failed |
| One with recent activity, a Next Step, or a Close Date in this quarter | Pass |
| Two, each with only one or two of the signs | Pass |
Also run the failing case as a user who cannot see that Opportunity; the result follows that user’s access.
What users see
Section titled “What users see”A failed row shows Failed, because Failure Severity is Critical, with the message, the fix
message, and a Review open Opportunities link. Found shows the count of risky Opportunities, and
Expected shows 0. An Apex Check’s Expected value has no comparison wording such as “to equal”.
Resolve problems
Section titled “Resolve problems”| What you see | What to check |
|---|---|
| Unable to Check with the class not found | The class is deployed, and Apex Class is exactly AccountOpenOpportunityHealthCheck. |
| An Opportunity with all three signs passes | All three conditions are true on that one Opportunity, and Apex Parameters (JSON) is valid. |
| Skipped on an Account with open Opportunities | The user can see them, and Applies When (Count Query) matches the table. |
| System Error | The user can read Opportunities and the queried fields. |