Skip to content

Save or send results after a run

4 guides

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.

RequirementApproach
The Flow or Apex code that runs the Checks needs the resultUse the result returned by the Flow action or the Apex API. Publish nothing.
A custom Batch job must save results as it runsSave 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 itselfPublish a Platform Event.
A person runs the Checks on the record-page card, and the result must be saved or routedPublish a Platform Event. The card has no other way to hand results to automation.
Results must be kept for reports or auditsSave 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.

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 EventAPI name in your orgOne event representsUse it when
Record Health Check Set Runrhc__Record_Health_Check_Set_Run__eThe result counts for one record after a runCounts are enough, such as 4 passed and 1 failed. Start here for history.
Record Health Check Resultrhc__Record_Health_Check_Result__eThe result of one Check for one recordAutomation must know which Check failed, and its severity and Reason Code.
Record Health Check Logrhc__Record_Health_Check_Log__eOne technical error, with its message and stack traceRestricted 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.

What controls publication depends on what starts the run:

The run starts fromPublication control
A person selecting Run or Rerun on the cardPublish 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 saveNothing publishes.
A Flow, Apex code, or a Queueable, Batch, or Scheduled jobThe caller’s Event Publication value: NONE, ACTIONABLE, or ALL. The card checkboxes do not apply.
An Agentforce action, the MCP service, or a PreviewNothing publishes.
Any run that captures a technical errorPublish 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.

Receiving optionUse it whenConsider
Platform Event-triggered FlowAn 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 triggerA 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 APIA 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”
  1. Create a custom object for the history, such as Health Check Run History. Record Health Check does not create it.
  2. Add a Text(80) Event ID field and mark it Unique, so the same event cannot create two records.
  3. Add fields for the event values you want to keep. Save Check Set run summaries lists each field and its suggested type.
  4. 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 ACTIONABLE or ALL.
  5. In Setup → Flows, select New Flow → Platform Event—Triggered Flow, and choose Record Health Check Set Run.
  6. 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.
  7. Add a Create Records element that saves the history record, and connect its fault path to your organization’s Flow error handling.
  8. Run the Checks, confirm that one history record appears for the record you checked, and then activate the Flow in production.

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__c in 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__c to 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.
SituationWhat the receiving automation should do
The Event ID is already savedEnd successfully without repeating the work.
A record is locked or an external service is unavailableRetry a limited number of times. Make every action safe to repeat.
The event has a Contract Version or value it does not handleSave the event for review and continue, so one event does not block the ones after it.
Some records in an Apex trigger fail to saveRecord 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 periodRecover 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.

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.

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 each of these cases in a sandbox:

  1. An event creates the expected record or action.
  2. The same Event ID received twice does not repeat the work.
  3. An event with a blank optional field, such as Record ID, is processed without a fault.
  4. An unexpected status or Contract Version goes to review.
  5. A failed save is visible to administrators.
  6. Users without access cannot read the saved results.
  7. An external subscriber resumes from its saved Replay ID.

After activation, monitor failed Flow interviews, Apex errors, and Platform Event usage.