Save or send results after a run
Keep a history of Record Health Check results, or start other automation when a Check fails, by receiving the Platform Events that Record Health Check publishes after a run. A separate Flow, Apex trigger, or external integration receives the events and saves or routes the results; the process that ran the Checks does not wait for it.
For example, a nightly Batch job checks every customer Account. A Platform Event-triggered Flow receives one summary per Account and saves it in a custom history object, so administrators can report on how Account data quality changes over time.
Platform Events are optional, and every publication setting is off by default. Record Health Check does not store results itself.
Decide whether you need a Platform Event
Section titled “Decide whether you need a Platform Event”| Requirement | Approach |
|---|---|
| The Flow or Apex code that runs the Checks needs the result | Use the result returned by the Flow action or the Apex API. Publish nothing. |
| A custom Batch job must save results as it runs | Save the result returned to the Batch execute() method. Publish nothing. |
| A separate Flow, Apex trigger, or integration must receive results that it did not request itself | Publish a Platform Event. |
| A person runs the Checks on the record-page card, and the result must be saved or routed | Publish a Platform Event. The card has no other way to hand results to automation. |
| Results must be kept for reports or audits | Save the results in a custom object your team creates. Platform Events are not permanent storage. |
Using the returned result is easier to follow and test, and it does not use your org’s Platform Event allocations.
Choose a Platform Event
Section titled “Choose a Platform Event”Record Health Check includes three Platform Events. In your org, their API names and their fields
carry the package’s rhc__ namespace prefix, such as rhc__Record_Health_Check_Set_Run__e and
rhc__EventId__c.
| Platform Event | API name in your org | One event represents | Use it when |
|---|---|---|---|
| Record Health Check Set Run | rhc_ | The result counts for one record after a run | Counts are enough, such as 4 passed and 1 failed. Start here for history. |
| Record Health Check Result | rhc_ | The result of one Check for one record | Automation must know which Check failed, and its severity and Reason Code. |
| Record Health Check Log | rhc_ | One technical error, with its message and stack trace | Restricted support automation must investigate errors inside Record Health Check. |
The Set Run and Result events contain IDs, API names, statuses, and counts. They never contain field values, messages, formulas, or queries. The Log event can contain error messages and stack traces, so restrict who can receive it.
For every field of every event, see the Platform Event field reference.
Turn on publication
Section titled “Turn on publication”What controls publication depends on what starts the run:
| The run starts from | Publication control |
|---|---|
| A person selecting Run or Rerun on the card | Publish User Run Event on the Check Set and Publish User Result Event on each Check. Both are cleared by default. |
| The page opening, or the card refreshing after a save | Nothing publishes. |
| A Flow, Apex code, or a Queueable, Batch, or Scheduled job | The caller’s Event Publication value: NONE, ACTIONABLE, or ALL. The card checkboxes do not apply. |
| An Agentforce action, the MCP service, or a Preview | Nothing publishes. |
| Any run that captures a technical error | Publish Error Log Event on the Check Set publishes a Log event. It is cleared by default and requires the Record Health Check Error Log Publisher permission set. |
Decide when to use Platform Events describes exactly which events each setting publishes.
Choose how to receive the events
Section titled “Choose how to receive the events”| Receiving option | Use it when | Consider |
|---|---|---|
| Platform Event-triggered Flow | An administrator needs to create records, assign work, or send notifications without code. | Check for a duplicate Event ID before creating anything, and connect fault paths. |
| Apex trigger | A development team needs bulk processing, complex routing, or reusable handlers. | Write tests, keep queries and saves outside loops, and handle each failed save. |
| External subscriber with Pub/Sub API | A data warehouse, middleware, or monitoring tool outside Salesforce needs the events. | Save the Replay ID after each event is processed, and reconnect before Salesforce’s retention ends. |
The receiving automation runs separately from the Checks. If it fails, the result already returned to the person, Flow, or Apex code does not change.
Quick start: save Check Set summaries with Flow
Section titled “Quick start: save Check Set summaries with Flow”- Create a custom object for the history, such as Health Check Run History. Record Health Check does not create it.
- Add a Text(80) Event ID field and mark it Unique, so the same event cannot create two records.
- Add fields for the event values you want to keep. Save Check Set run summaries lists each field and its suggested type.
- Turn on publication for one Check Set in a sandbox. For the card, select Publish User Run
Event on the Check Set. For a Flow or Apex caller, use
ACTIONABLEorALL. - In Setup → Flows, select New Flow → Platform Event—Triggered Flow, and choose Record Health Check Set Run.
- Add a Get Records element that looks for a history record whose Event ID equals
{!$Record.rhc__EventId__c}. When one exists, end the Flow. - Add a Create Records element that saves the history record, and connect its fault path to your organization’s Flow error handling.
- Run the Checks, confirm that one history record appears for the record you checked, and then activate the Flow in production.
Handle repeated events
Section titled “Handle repeated events”Receiving automation must give the same outcome when it receives the same event again, for example after a retry or a replay.
- Save
rhc__EventId__cin a field marked Unique. Each event has a different Event ID. - Before creating a record, a Task, or a notification, check whether the Event ID is already saved. If it is, end without repeating the work.
- Use
rhc__RunId__cto group the events of one run. Do not use it as a unique key: one run can publish events for many records and Checks. - An external subscriber stores the Replay ID to know where to resume reading. The Replay ID does not replace the Event ID check.
Plan for failures
Section titled “Plan for failures”| Situation | What the receiving automation should do |
|---|---|
| The Event ID is already saved | End successfully without repeating the work. |
| A record is locked or an external service is unavailable | Retry a limited number of times. Make every action safe to repeat. |
| The event has a Contract Version or value it does not handle | Save the event for review and continue, so one event does not block the ones after it. |
| Some records in an Apex trigger fail to save | Record each failed Event ID and its error. Do not report the whole group as saved. |
| The receiving automation is turned off or fails for a period | Recover from your saved history or rerun the Checks. Salesforce keeps events for 72 hours. |
An Apex Platform Event trigger can also set a resume checkpoint or throw a retryable exception. See Salesforce’s Platform Event Apex trigger documentation.
Retention and replay
Section titled “Retention and replay”All three events are high-volume Platform Events, which Salesforce keeps for 72 hours. Save the results in your own object or system when they must be kept longer.
An external subscriber saves the Replay ID of the last event it processed. After reconnecting, it asks for the events after that Replay ID. Replay IDs are not consecutive; never calculate one. See Salesforce’s Event Message Durability.
Publishing events counts toward your org’s Platform Event allocations. Review them in Salesforce’s Platform Event Allocations before you publish a Result event for every Check.
Access
Section titled “Access”The Record Health Check Card User, Record Health Check User, and Record Health Check Admin permission sets grant Create and Read access to the Set Run and Result events, so the people and automation that run Checks can publish them. None of them grants access to the Log event; the separate Record Health Check Error Log Publisher permission set does.
Also review access for:
- the user that the Platform Event-triggered Flow, Apex trigger, or integration runs as;
- the custom object that stores the events, and its fields;
- the Salesforce records named by the Record ID in each event; and
- every email, Slack channel, or queue that receives event details.
Test before activation
Section titled “Test before activation”Test each of these cases in a sandbox:
- An event creates the expected record or action.
- The same Event ID received twice does not repeat the work.
- An event with a blank optional field, such as Record ID, is processed without a fault.
- An unexpected status or Contract Version goes to review.
- A failed save is visible to administrators.
- Users without access cannot read the saved results.
- An external subscriber resumes from its saved Replay ID.
After activation, monitor failed Flow interviews, Apex errors, and Platform Event usage.