Skip to content

Check open Opportunity health with Apex

Configure a custom Apex Check that fails only when an open Opportunity is stale, has no Next Step, and has a Close Date outside the current quarter.

The rule combines several Opportunity conditions and activity logic. Reviewed Apex keeps that logic testable while returning one clear card result.

  • Have a Salesforce developer review, deploy, and test AccountOpenOpportunityHealthCheck from the developer reference. This class is an integration example, not a packaged runtime class.
  • Agree on the stale-activity window; this example uses 30 days.
  • Confirm intended users can read every Opportunity field used by the class.
  • Save configuration inactive until the Apex tests and configuration validation succeed.

Use or create the Account Apex Readiness Check Set and leave it inactive.

Then create:

Salesforce fieldValue
LabelOpen Opportunities Are Healthy
Record Health Check NameOpen_Opportunities_Are_Healthy
Check SetAccount Apex Readiness
Check TitleOpen Opportunities are healthy
Evaluation TypeVerify with Apex
Apex ClassAccountOpenOpportunityHealthCheck
Apex Parameters (JSON){"staleDays": 30}
Failure SeverityCritical
Message When Failed{!record.Name fallback="This Account"} has one or more open Opportunities that are stale, missing Next Step, and outside the current quarter.
Fix MessageReview activity, Next Step, and Close Date on each unhealthy Opportunity.
Action LabelReview open opportunities
Action URL/lightning/r/Account/{!record.Id}/related/Opportunities/view
Evaluation Order20
ActiveUnchecked until validation succeeds
  1. Require a passing Apex test deployment.
  2. Run the configuration-validation Flow.
  3. Activate only after both checks succeed.
  4. Assign Record Health Check Card User.

Test a healthy deal and each rule individually, then one deal that meets all three failure conditions. Repeat with intended record and field access.

The Apex class returns the outcome and display values after applicability and prerequisite checks.

Result detailMeaning
PASSThe class reports that the configured business rule is satisfied.
FAILThe class reports a normal business-rule failure, and the card shows the configured guidance.
SKIPPEDThe Check does not apply or a prerequisite prevents the Apex class from running.
FoundThe class-provided value that explains the observed record state.
ExpectedThe class-provided target or comparison value.

Confirm the class name, deployed Apex test result, JSON parameter, and running user’s access before changing the business rule.

See Open Opportunity health implementation for complete source, tests, context/result contracts, security behavior, and customization.