Skip to content

Draft Check configuration with AI

Detailed page. Use “On this page” to jump directly to the section you need.

Pick one Evaluation Type prompt, paste it into an approved AI assistant with your business requirement, then verify every suggested Salesforce API name before entering anything in Setup.

Use this folder as the single place to draft Record Health Check configuration with an AI assistant. An assistant can organize a requirement and suggest fields. It cannot know your org’s fields, sharing, or approved rules unless you provide them. Treat every answer as a draft.

The self-contained prompts are reviewed against the Record Health Check metadata and runtime contract. The offline release gate checks all 63 configurable fields, 21 restricted picklists, the shared prompt block, and one provider-neutral reference draft for each Evaluation Type.

  • Review and approve every AI suggestion before entering it in a production org.
  • Verify object, field, relationship, Check Set, Check, report, and Apex class API names in the target Salesforce org.
  • Use approved, non-sensitive inputs that exclude customer data, credentials, Salesforce session details, and other restricted information.
  • Activate a Check after an administrator has tested pass, fail, skipped, access-restricted, and unable-to-evaluate cases in a sandbox.

Follow your organization’s AI, privacy, security, and change-management policies. Use only an AI product your organization approves. This guide does not require or endorse a particular vendor.

  1. Fill in the requirement template. The Before you ask section identifies the information the AI needs.
  2. Give this README link to an AI that can open linked pages, together with the filled requirement. Tell it to follow this guide, ask rather than guess, and return a proposal for human review.
  3. The assistant chooses the simplest Evaluation Type that safely expresses the requirement. It must then open the chosen Evaluation Type prompt from the table below and follow that page’s complete prompt block. The assistant should explain why it selected that type and show a materially different alternative only when the requirement leaves a real design choice.
  4. If the assistant cannot open links, use the table to choose the likely Evaluation Type, open its prompt page yourself, and copy the single system-prompt block followed by the filled requirement. Each prompt is self-contained: it carries the shared rules, every Check Set field, and every Check field.
  5. Review the draft against the field references and examples linked from the selected prompt page.
  6. Keep the proposed Check Set and Check inactive. Enter approved values in a sandbox, then follow Test the human-approved draft.
  7. For an unsaved Check, use Validate and preview an AI draft before activation when the Preview component is installed.
  8. Choose and test the complete entry and exit path. A valid evaluation rule is incomplete until its actual caller, execution principal, result destination, consumer, and failure recovery are known.
  9. When the caller or consumer does not exist yet, use the execution workflow generator to draft the Flow, synchronous Apex caller, Queueable, Batch, Scheduled adapter, persistence service, or event receiver. Keep generated source under normal test-first, security-review, and deployment controls.
CapabilityWhat the assistant must decide
Card presentationHeading, summary placement or hiding, reveal mode, Found/Expected placement, and Run/Rerun controls are independent choices.
DependenciesEvaluation Order controls presentation; prerequisite dependency order controls execution and may point to a later-displayed Check.
Query-row valuesZero-based row tokens, outer-field selection, business ORDER BY, single-row proofs, child-subquery boundaries, and per-record LIMIT behavior.
Inline linksSafe {!link label="..." href="..."} links in message and display fields, with readable text fallback.
Whole-set limitsMore than 25 active Checks rejects the complete Check Set instead of returning a partial result.
Apex extensionsTyped parameter definitions, typed outcomes, evidence, per-record recovery, and optional display-only overrides.
Draft verificationInactive metadata, detached validation/Preview, representative records, permissions, limits, namespaces, and relevant runtime variations.
Operational boundaryLightning, Flow, synchronous Apex, Queueable, Batch, or Scheduled entry; direct, event, readiness, diagnostic, or subscriber-owned result exit.
Where the answer comes fromEvaluation TypeCopy this promptConfirm against
Fields on the current record or a formula-reachable parentVerify with a formulaFormula promptFormula examples, Check fields
Records or a value from one SOQL queryVerify with a queryQuery promptQuery examples, Query reference
Two separate SOQL query resultsCompare two queriesCompare two queries promptCompare two queries examples
Logic that formula and query settings cannot express safelyVerify with ApexApex promptApex Check contract, Apex examples

If the requirement must prevent Salesforce from saving a record, use a Validation Rule, record-triggered Flow custom error, or Apex trigger instead. Record Health Check never blocks a save.

Every prompt repeats the merge-token, Check Set, Check, and safety rules from Shared rules word for word. Change that page when product behavior changes, then regenerate the four prompts from it. npm run check:ai-prompts fails when a prompt drifts from the shared block, names a field or stored value the Check metadata does not declare, or stops offering a configurable field to the assistant.

These examples are representative, not the complete token reference:

  • Record value in SOQL, always unquoted: WHERE AccountId = {!record.Id}
  • Formatted record value in display text: {!record.Amount format="CURRENCY" fallback="Not available"}
  • Check and Check Set values in display text: {!rhcCheck.checkTitle} and {!rhcSet.cardTitle}
  • Result and run values in messages or Display Found/Expected Text: Found {!rhcResult.foundValue}; expected {!rhcResult.expectedValue}. Run {!rhcRun.runId} returned {!rhcResult.status}. {!rhcResult.failedRecordCount} of {!rhcResult.totalRecordCount} contacts are incomplete.
  • Zero-based query-row value after selecting and deterministically ordering the outer field: SELECT Name FROM Opportunity WHERE AccountId = {!record.Id} ORDER BY CreatedDate ASC LIMIT 1 with Oldest deal: {!rhcQuery.sourceRows[0].Name fallback="none"}.
  • Query row counts: {!rhcQuery.sourceRowCount} and {!rhcQuery.comparisonRowCount}.
  • Inline link inside a supported message or display field: {!link label="Open record" href="/lightning/r/Account/{!record.Id}/view"}
  • Action URL: /lightning/r/Account/{!record.Id}/related/Contacts/view

rhcResult properties are status, foundValue, foundValuePluralSuffix, expectedValue, failedRecordCount, totalRecordCount, and reasonCode. Do not put rhcResult tokens in SOQL or Action URL. rhcQuery is available only to Query and Compare Two Queries Checks after the addressed query runs; row indexes start at zero, child-subquery fields are opaque, and a multi-row query needs an explicit business ORDER BY. Do not use Flow/API names such as evaluation.found or actualValue as merge tokens.

Full token list: Merge syntax.

QuestionExample answer
Which Salesforce object is checked?Account (Account)
What must be true?The Account has at least one Contact.
Where does the answer come from?Contact records related through Contact.AccountId.
What should happen when no Contact exists?Fail.
What should users see?Add at least one verified Contact before handoff.
Does the Check apply to every record?Yes.
Should it block a save?No. It is guidance during an Account handoff.
Which users will run it?Account managers with access to the Contacts they manage.

Copy API names from Setup → Object Manager → [Object] → Fields & Relationships. Open the field and copy Field Name. Do not provide a label such as “Customer Tier” and expect the assistant to guess whether the API name is Customer_Tier__c.

Confirm Check Set values against Check Set fields. Confirm Check values against Check fields and a matching page in the examples library.

Do not approve a draft unless it explains PASS, FAIL, SKIPPED, UNABLE_TO_EVALUATE, and ERROR. Sharing matters: a hidden related record is not counted, and missing object or field access can produce UNABLE_TO_EVALUATE.

For Apex drafts, a developer must review, test, and deploy the class before anyone enters the class name in Check metadata. See the Apex prompt and Apex Check contract.

ReviewRequired human decision
Business ownerWhat passes, fails, and skips; severity; wording; and whether the result is useful enough to activate.
Salesforce administratorExact API names, Setup values, Check Set membership, sharing behavior, permission assignments, page placement, and sandbox evidence.
Apex and security reviewerEvery custom class, user-mode data access, bulk behavior, parameter definition, evidence disclosure, display-only behavior, and prohibited actions.
Integration ownerPlatform Event publication, receiving automation, retention, retry behavior, and monitoring.

AI output never completes these approvals. A person must reread the final configuration after the last edit; an earlier review does not cover a changed formula, query, JSON value, message, or link.

  1. In sandbox Setup, open Custom Metadata Types → Record Health Check Set → Manage Records → New, then enter the approved Check Set with Active unchecked.
  2. Open Custom Metadata Types → Record Health Check → Manage Records → New, then enter the approved Check with Active unchecked.
  3. Review the saved values in Setup; do not rely on the AI response as the source of truth.
  4. Run detached Validate and Preview first when available. Activate the Check and Check Set only for controlled sandbox testing.
  5. Test a record that should pass.
  6. Test a record that should fail.
  7. Test every intended skip condition, including prerequisites and zero-row choices.
  8. Test as a user with restricted sharing.
  9. In a sandbox-only test, remove access to a required field and confirm UNABLE_TO_EVALUATE. Restore access afterward.
  10. Confirm messages and action links remain useful without diagnostics.
  11. Obtain the business owner’s approval before moving the configuration to production.
  • The base object and every field and relationship API name were copied from Salesforce Setup.
  • The business owner confirmed pass, fail, skip, and zero-row behavior.
  • The Check uses the simplest Evaluation Type that meets the requirement, and Evaluation Type is set.
  • Every picklist value in the draft is the stored value, not the Setup label.
  • Formula Result Type is AUTO unless a Query Check uses Expected Value (Formula) or Value to find in the list (formula) and a reviewer verified the operand’s exact type; no proposed value is the literal text N/A.
  • The Check Set and Check names are administrator-created names unless the exact installed package metadata is intentionally reused.
  • No one added or removed the rhc__ namespace prefix manually.
  • The proposal distinguishes hidden records from missing object or field access.
  • SOQL and messages use Record Health Check merge tokens ({!record.Id}), not Flow or Apex bind syntax.
  • Failure and fix messages use everyday business language.
  • Platform Event publication remains off unless receiving automation exists and is tested.
  • Any Apex class exists in the org and passed developer review and tests.
  • An intended user tested the configuration in a sandbox.
ProblemCorrect response
It invents an API nameStop and copy the exact API name from Salesforce Setup.
It prefixes a new Check Set or Check with rhc__Remove the invented namespace. Administrator-owned metadata normally has no managed-package prefix.
It chooses a Check included with the package when you need your own ruleCreate an administrator-owned Check with a name that normally has no rhc__ prefix.
It uses {!record.id}, {!Id}, {!$Record.Id}, :recordId, or quoted '{!record.Id}' Replace with Record Health Check merge tokens only. In SOQL use {!record.Id} unquoted; copy field API names from Setup.
It puts merge tokens in Pass ConditionRewrite as a Salesforce formula (NOT(ISBLANK(BillingCity))). Merge tokens belong in queries, messages, and Action URLs.
It assumes zero query rows should pass or failAsk the business owner; then configure If Query Finds No Records where the Evaluation Type uses it.
It omits Evaluation TypeEvery Check needs EvaluationType__c. There is no default.
It stores a Setup label instead of the stored valueEnter the stored value: Skip is SKIP, and When a count query matches is WHEN_COUNT_QUERY_MATCHES. Confirm each one in Check fields.
It proposes N/A for Formula Result Type or another metadata fieldUse the field’s deployable stored value, or omit an unused field from metadata. Use AUTO for Formula Result Type unless a Query Check’s Expected Value or Value-to-find operand formula has a verified exact type.
It recommends Record Health Check to prevent a saveUse a Validation Rule, Flow custom error, or Apex trigger.
It recommends an Apex example class that is not installedCreate, test, and deploy the class, or choose a metadata-only Evaluation Type.
It says a hidden related record is clean dataCorrect the wording: the Check evaluates only records visible to the running user.
It omits UNABLE_TO_EVALUATE and ERROR testingAdd access, configuration, and unexpected-error test cases before approval.