Skip to content

Asynchronous Apex

Guide1 min read

Run Record Health Check in the background with Queueable, Batch, or Scheduled Apex, so the code that changes records does not wait for the Checks. Record Health Check provides a ready-made class for each, and you can also write your own class that calls rhc.RecordHealthCheck.evaluate.

NeedGuide
Check up to 200 known records in a later transactionRun Record Health Check from Queueable Apex
Check up to 2,000 known records, or millions found by a queryCheck many records with Batch Apex
Check records on a recurring scheduleRun Record Health Check from Scheduled Apex
Move existing @future codeReplace a Future method with Queueable Apex
Packaged classStarts withRecords
rhc.RecordHealthCheckQueueablerhc.RecordHealthCheckQueueable.enqueue(...)1–200 known IDs
rhc.RecordHealthCheckBatchrhc.RecordHealthCheckBatch.run(...)1–2,000 known IDs
rhc.RecordHealthCheckScheduledrhc.RecordHealthCheckScheduled.scheduleDaily(...)1–2,000 known IDs, every day at 2:00 AM

The packaged classes return only a job ID; they do not return or save results. To receive their results, pass ACTIONABLE or ALL and receive the Platform Events, as described in Save or send results after a run. To save results directly, write your own class.

Every packaged class requires the Record Health Check Run custom permission, which Record Health Check User includes, when the job is submitted and again when it runs. A completed job in Setup → Apex Jobs does not mean that every record passed.