Skip to content

Supporting Apex classes (L2-L5)

Use this page when tracing runtime support classes. This class-level reference is not a Setup or Flow walkthrough. Administrators should use the Flow, configuration, and evaluation guides; subscriber developers should use the public Apex API or Apex Check contract.

Use this page to identify supporting package classes referenced in an error, debug log, or code review. To call Record Health Check from custom Apex, use a documented global class instead of these internal classes.

Start with Entry points when choosing an API to call.

Batch, Queueable, Scheduled, and Flow support

Section titled “Batch, Queueable, Scheduled, and Flow support”

Prepares record IDs for Batch, Queueable, and Scheduled Apex. It removes null and repeated IDs, keeps the remaining IDs in a predictable order, and confirms that the request came from Batch, Queueable, or Scheduled Apex.

Type: global with sharing; implements Database.Batchable<Id>

Runs a Check Set when Apex already has the record IDs. run(...) chooses an automatic formula-safe scope of 1–100 records per transaction. The explicit scope overload accepts a caller-selected number from 1 through 200 and validates the formula budget before submission. See Batch Apex for examples and guidance on choosing that number.

Type: global with sharing; implements Queueable and Finalizer

enqueue(...) makes a copy of the request and starts Queueable Apex. The Queueable runs the health check. Its Finalizer records whether the Queueable completed even when the Queueable transaction fails. See Queueable Apex.

Type: global with sharing; implements Schedulable

scheduleDaily(...) creates a schedule that runs every day. Salesforce calls execute at the scheduled time to start the configured health check. See Scheduled Apex.

Keeps the JSON returned to Flow within the package limit, builds one Flow response per input record, reads NONE, ACTIONABLE, or ALL, and calculates the overall Status. It reports invalid input separately from a response that is too large.

Combines Flow inputs that use the same Check or Check Set Qualified API Name and the same Platform Event choice. It checks the maximum number of groups before work begins, then returns each result to the matching Flow input.

Type: global enum

Controls Platform Events for Apex, Flow, Batch, Queueable, and Scheduled runs: NONE publishes no results, ACTIONABLE publishes FAIL, UNABLE_TO_EVALUATE, and ERROR, and ALL publishes every result. Programmatic requests default to NONE. These choices do not use the Lightning card’s publication settings.

Type: global enum

Identifies how the health check started: APEX_API, FLOW, USER_INITIATED, RUN_ON_LOAD, BATCH, QUEUEABLE, SCHEDULED, FUTURE, or AGENT.

Finds the class named by an Apex Check, including a namespace prefix when present, and confirms that the class implements RecordHealthCheckPlugin. A missing class, invalid JSON parameters, or wrong class type raises PluginConfigurationException.

Converts a custom Apex Check outcome into the package’s internal result. It formats Found and Expected values and applies the final Status, Reason Code, and display text.

Supports Compare two queries Checks. It resolves one value from each query or cleans up two lists before applying list operators. Lists Match Exactly also checks repeated values, so [A, A] does not equal [A].

Adds formatted values and messages after a Formula Check has already determined its Status.

Recognizes supported Formula tokens and formula keywords while validating and preparing a Formula Check.

Coordinates resolved Query Check inputs, compares Found and Expected values, and builds the internal result with display formatting and value provenance.

Resolves the primary and comparison query or formula inputs. Retains queried rows before cardinality errors, distinguishes empty comparison queries from null values, and returns the configured early result when a single-row primary query has no matching rows.

Replaces supported record.* tokens in SOQL, escapes text safely, rejects disallowed SOQL keywords, and builds INCLUDES values for multi-select picklists.

Reads fields through Salesforce relationships and converts token fallback text to the selected field’s data type, including Date, Datetime, Time, and multi-select picklist values.

Checks PrerequisiteCheck__c relationships and returns ValidationIssue entries when a dependency is missing, invalid, or cannot run in the selected order.

Converts the first Check configuration problem into an UNABLE_TO_EVALUATE result. buildUnableResult supplies the same safe result format for each problem.

Loads the Lightning card definition, validates its Check Set and active Checks, applies the Check limit, reports inactive Checks, and selects the executable subset.

Converts Check configuration findings into the ValidationIssue entries returned by the package’s metadata audit.

Validates Check Set-level card behavior and publication settings separately from per-Check evaluation configuration.

Reads package settings used internally for Platform Event publication. Custom Apex in an org that installs the package should not call this class.

Display, diagnostics, and identity helpers

Section titled “Display, diagnostics, and identity helpers”

Builds readable operator labels and Found and Expected text for single-value and list comparisons.

Owns the per-Check ComparisonDisplayMode__c setting: it normalizes the configured value (blank and unrecognized values resolve to AUTOMATIC), reports an unsupported value to metadata validation, and flags a Check set to Hide that offers the user no failure message, Fix Message, or Action URL. The setting is presentation only and is not a security control.

Adds troubleshooting details when the running user is allowed to view diagnostics. It does not change the health result.

Builds consistent run, Check, evaluator, component, query-side, and lifecycle-phase context at scope evaluator boundaries before an incident is classified.

Represents one typed corrective action in a diagnosis, including its stable action kind, label, instruction, and optional Setup target.

Carries server-only failure context into the classifier. It is not returned to users and keeps raw exception handling separate from the public diagnostic contract.

Creates a versioned diagnostic incident from either a caught exception or a stable reason code. It classifies ownership, category, phase, retryability, top Apex frame, and a value-free fingerprint.

Maps diagnostic families to plain-language summaries, likely causes, corrective actions, and verification steps for configuration, access, Formula, Query, Apex, limit, and framework failures.

Defines the common diagnosis shared by the Lightning card, browser console, Apex API, Agentforce actions, and structured error telemetry. Restricted evidence is separated from safe summary and remediation fields.

Atomically creates technical results and their diagnostic incident, records structured telemetry, and attaches diagnoses to reason-only ERROR and UNABLE_TO_EVALUATE outcomes.

Formats a currency value using the requested Value Format, decimal places, and ISO currency code.

Determines whether to use the currency from a query row, related field path, checked record, or the org’s corporate currency. It also detects whether multiple currencies are enabled.

Reads a query field’s Salesforce type and determines its display format, including multi-select picklist values.

Converts supported numeric values to a consistent type and formats them with either automatic or fixed decimal places.

Formats Boolean, Date, Datetime, Time, and multi-select picklist values for messages and the Lightning card.

Validates a Check or Check Set Qualified API Name. It rejects a label and rejects a name that is ambiguous because its required namespace prefix is missing.

Separates ordinary text from merge tokens, validates where each token is allowed and which settings it uses, reports invalid tokens, and lists the Salesforce record fields referenced by the template.

Replaces tokens with values from Salesforce fields, Check and Check Set Custom Metadata, completed results, and run details.

Request, response, and custom Apex Check types

Section titled “Request, response, and custom Apex Check types”

Type: global abstract

Provides test data for RecordHealthCheckContractTest, including the optional PermissionFixture used to verify behavior for a user with limited access. A custom Apex Check test can extend this class; production automation should not call it.

Stores a result while package classes evaluate a Check, add diagnostics, and create display text. The package converts it to the global response types before returning it to custom Apex.

Type: global; each method returns a new object instead of changing the existing one

Stores the requested response content, Platform Event choice, optional run ID, and how the request started. defaults() returns evaluation results, publishes no events, and uses APEX_API. Each with... method returns a new options object instead of changing the existing one.

Type: global

Result returned by a custom Apex Check. Factory methods create PASS, FAIL, UNABLE_TO_EVALUATE, SKIPPED, or ERROR. withFound, withComparison, and withExpected add values while preserving their Salesforce data types.

Calls a custom Apex Check and verifies that it returns exactly the requested record IDs and supported Statuses. It also rejects record changes, callouts, queued work, future calls, and email. An invalid result and a prohibited action use different errors.

Type: global; each method returns a new request instead of changing the existing one

Creates requests for one or more records with forCheckSet(...) or forCheck(...). Its recordIds getter returns a copy, and every with... method returns a new request instead of changing the existing one.

Type: global enum

Controls how much information the response contains: EVALUATION, EVALUATION_WITH_DISPLAY, or SUMMARY. It does not change which Checks run or how their Status is calculated.

Type: global

Counts PASS, FAIL, SKIPPED, UNABLE_TO_EVALUATE, and ERROR results. total() adds those counts. The class does not convert them to a separate pass-or-fail decision for the entire request.

Type: global; cannot be changed after creation

Identifies exactly one Check Set or one Check by its Qualified API Name. It rejects a blank or invalid name.

Type: global abstract constants holder

Defines PASS, FAIL, SKIPPED, UNABLE_TO_EVALUATE, and ERROR. isActionable returns true only for FAIL, UNABLE_TO_EVALUATE, and ERROR.

Type: global

Value returned by a custom Apex Check. Factory methods preserve String, Boolean, Number, Date, Datetime, ID, Count, and List types.