Troubleshoot execution context
Find out why the same Check gives one result on the record-page card and another in a Flow, Apex code, or a background job. The cause is almost always that a different Salesforce user runs the Checks in each place, with different access, time zone, or permissions.
Record Health Check never runs with more access than the user who runs it. It reads every record and field with that user’s object permissions, field permissions, sharing, restriction rules, and scoping rules, even when a Flow runs in system context.
Find the user who runs the Checks
Section titled “Find the user who runs the Checks”| What runs the Checks | The Checks run as |
|---|---|
| The record-page card | The user viewing the record |
| A screen Flow | The user running the Flow |
| A record-triggered Flow | The user who saved the record |
| Apex code | The user whose transaction runs the code |
| A Queueable or Batch job | The user who submitted the job |
| A Scheduled job | The user who scheduled the job |
| A Platform Event trigger or Platform Event-triggered Flow | The Automated Process user, unless the trigger is configured to run as another user |
Every one of these users needs the Record Health Check Run custom permission, which Record
Health Check User includes. Without it, a Flow action returns Error Type AUTHORIZATION, and
Apex and async jobs throw an authorization error. The card needs Record Health Check Card User
or Record Health Check User.
Record what you see
Section titled “Record what you see”Before you change anything, record for each place the Check runs:
- the record ID, the Check or Check Set Qualified API Name, the status, and the Reason Code;
- the Run ID, when the console report or a Platform Event shows it;
- the user who ran the Checks, from the table above; and
- the exact time and that user’s time zone.
Stop retries and repeated jobs while you investigate, so new runs do not change the evidence. Do not grant administrator access or rewrite the Check in system mode to make the results match: that hides the access difference instead of fixing it.
The card passes, but a Flow returns Unable to Check
Section titled “The card passes, but a Flow returns Unable to Check”What you see: The card shows Pass. The Flow action returns Status
UNABLE_TO_EVALUATE, for example with Reason Code CANNOT_EVALUATE or RECORD_NOT_VISIBLE.
Public results report a field or record the user cannot read as CANNOT_EVALUATE; with
Show Diagnostics, an authorized user sees the
specific FIELD_NOT_ACCESSIBLE reason and the field.
Cause: The Flow runs as a different user, who cannot read a field or record the Check uses. Running the Flow in system context does not change this.
Fix:
- Identify the Flow’s running user from the table above.
- Compare that user’s access with the card user’s for every field the Check reads, including the fields in its formulas and queries, and for the records those queries read.
- Give the Flow’s running user the access the Check needs, or run the Flow as a user who has it.
- Debug the Flow with the same record. In Flow Builder, select Debug and, when your org allows it, Run flow as another user.
A formula that uses $User returns Unable to Check
Section titled “A formula that uses $User returns Unable to Check”What you see: A Formula Check such as OwnerId = $User.Id returns Unable to Check with
Reason Code INVALID_FORMULA everywhere it runs.
Cause: Formula Checks support the record’s fields, not global variables such as $User.
Record Health Check returns UNABLE_TO_EVALUATE rather than a result that would change with the
running user.
Fix: Replace the global variable with a record field or a query. For example, to check that an
Account owner is active, use the formula Owner.IsActive, or a Verify with a query Check with
the query SELECT COUNT() FROM User WHERE Id = {!record.OwnerId} AND IsActive = true, How To Read
Query Results set to One row or aggregate, Comparison Operator set to Greater than, and
Expected Value (Fixed) set to 0. A bare COUNT() takes no alias, so leave Source Query
Field blank.
The result changes around midnight
Section titled “The result changes around midnight”What you see: A Check that uses TODAY() or NOW() gives different results on the card and
in a Scheduled job run near midnight.
Cause: TODAY() returns the date in the running user’s time zone. The card user and the user
who scheduled the job can be in different time zones, so their dates change at different times.
Fix:
- Record the time zone of every user who runs the Check.
- Compare the times in UTC.
- When every place must use the same cutoff, compare with a date stored on the record rather than
with
TODAY(), or schedule the job well away from midnight in every relevant time zone.
A Queueable or Batch job gives a different result
Section titled “A Queueable or Batch job gives a different result”What you see: The Checks pass when run directly, but a Queueable or Batch job fails or returns different results for the same records.
Cause: The job runs in its own transactions as the user who submitted it, and Record Health Check checks that user’s permission again when the job starts. Submitting the job proves only that Salesforce accepted it.
Fix:
- In Setup, open Apex Jobs, and find the job, its status, and its failed batches.
- Trace the submitting user with a debug log, and run one job again.
- Compare the job’s Check Set, record IDs, and Event Publication value with the direct run.
- When a query returns no rows in the job, remember that it returns only rows the user can see. No rows does not prove that no matching records exist.
A Scheduled job starts failing after an administrator change
Section titled “A Scheduled job starts failing after an administrator change”What you see: A Scheduled job that worked before now returns authorization errors or different results, although no Check changed.
Cause: The job runs as the user who scheduled it. When that user is deactivated, loses Record Health Check User, loses data access, or changes time zone, the job’s results change. The job checks the user’s permission each time it starts, and then runs the Checks in a Batch job.
Fix:
- In Setup, open Scheduled Jobs, and find the job and the user who submitted it.
- Confirm that the user is active, has Record Health Check User, can read the records and fields the Checks use, and has the expected time zone.
- When the job belongs to the wrong user, delete it and schedule it again as a dedicated automation user, rather than broadening the old user’s access.
Close the investigation
Section titled “Close the investigation”Keep a short record of the cause, the fix, and the result of running the same record again from every place the Check runs. Then remove temporary trace flags and diagnostics access. Do not keep access tokens, session IDs, or unredacted record values in tickets or shared logs.