Platform Validation Rule Generate

作者 forcedotcom3c15867bdb9d無授權條款1K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫昨天更新

Use this skill when users need to create, modify, or validate Salesforce Validation Rules. Trigger when users mention validation rules, field validation, data quality rules, formula validation, error messages, or validation logic. Also use when users encounter validation errors, need to update formulas, or want to enforce business rules at the data layer. Always use this skill for any validation rule work.

AI 產生的概覽

指導建立、修改與驗證 Salesforce 驗證規則及其中介資料公式。

功能
此技能提供撰寫 Salesforce 驗證規則中介資料的說明,涵蓋 fullName、active、errorConditionFormula 與 errorMessage 等必要屬性。它列出公式函式使用準則與關鍵規則,包括將含 XML 標籤的公式放入 CDATA 區段,以及必須使用 .validationRule-meta.xml 副檔名。它也說明如何將更新指示理解為取代或附加公式邏輯。它產出的是指引與規則定義,而非執行指令碼。
適用情境
在建立、編輯或排解 Salesforce 驗證規則、欄位驗證、資料品質規則或公式驗證時使用。也適用於出現驗證錯誤、需要更新公式,或需要在資料層強制執行業務規則的情況。
執行需求
無需指令碼或特殊工具,僅為說明性內容。鎖定 API 版本 60.0 或以上的 Salesforce 驗證規則中介資料。

When to Use This Skill

Use this skill when you need to:

  • Create validation rules to enforce data quality
  • Prevent invalid records from being saved
  • Generate validation rule metadata with formulas
  • Add business logic validation to objects
  • Troubleshoot deployment errors related to validation rules

Specification

ValidationRule Metadata Specification

Overview

Validation Rules are declarative metadata components used to enforce data quality and business logic in Salesforce. They evaluate a formula expression when a record is saved and prevent the save operation if the expression returns TRUE.

Purpose

-Enforce business rules at the data layer -Prevent invalid or incomplete records from being saved -Display meaningful error messages to guide users

Required Properties

Core Validation Rule Properties
  • fullName

    • The unique API name of the validation rule
    • Must start with a letter
      • Can contain letters, numbers, and underscores
    • Cannot end with an underscore
    • Cannot contain consecutive underscores
    • Cannot exceed 40 character.
  • active -Indicates whether the validation rule is enabled true → Rule is enforced false → Rule is inactive

  • errorConditionFormula

  • The logical formula that evaluates record data

  • Must return TRUE or FALSE

  • If TRUE, the validation rule triggers an error

  • errorMessage

    • The message displayed to the user when validation fails
  • Maximum length: 255 characters

Specific Function Guidelines

  • TEXT - TEXT() function MUST NOT be used with Text fields, to fix this you can just remove the TEXT() function.
  • CASE - In salesforce CASE() function, last parameter is the default value. Admins often miss to provide this and number of parameters to CASE() function are always even.
  • VALUE - VALUE() function should only be used with Text fields. If a number is being used as a parameter to the VALUE() function, remove the VALUE() function.
  • DAY - DAY() function should only be used with Date fields. If a Datetime field is being used as a parameter to the DAY() function, convert it into a Date first.
  • MONTH - MONTH() function should only be used with Date fields. If a Datetime field is being used as a parameter to the MONTH() function, convert it into a Date first.
  • DATEVALUE - DATEVALUE() function should only be used with DateTime fields. If a Date is being used as a parameter to the DATEVALUE() function, remove the DATEVALUE() function.
  • ISPICKVAL - If checking equality of a picklist type field, the function ISPICKVAL() MUST be used.
  • ISCHANGE - Use ISCHANGE() function to check the value of a record has changed.

Critical Rules

  1. Formula XML Handling(MOST COMMON ERROR)

    • ANY errorConditionFormula containing XML tags MUST be inside a CDATA section in the metadata XML.
  2. Interpretation of "Update" Instructions. When receiving instructions to modify a formula, distinguish between a replacement and an addition:

    • "Update the formula to [Action]": Completely replace the existing formula logic with the new requirement.
    • "Update the formula to also [Action]": Keep the existing logic and append the new requirement (usually by wrapping the logic in an AND() or OR() function).
  3. File Format Requirement

    • Validation rule files MUST always use the .validationRule-meta.xml extension.

來源與署名

來源:forcedotcom/sf-skills位於plugins/builder/salesforce-development/skills/platform-validation-rule-generate提交3c15867

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架