跳到主要内容
知仓学习社ZHICANG

platform-validation-rule-generate

Use this skill when users need to create, modify, or validate Salesforce Validation Rules. Trigger when users mention validation rules, field valida…

不碰外部(只输出文字)无严重或高危命中forcedotcom/sf-skills

它会碰到什么

扫了多少1 个文本文件,4 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

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.
  1. 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).
  1. File Format Requirement
  • Validation rule files MUST always use the .validationRule-meta.xml extension.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

同名技能的其他版本

有 2 个不同仓库或目录里都有叫 platform-validation-rule-generate 的技能。它们内容并不相同,别混用:

  • forcedotcom/sf-skills — Use this skill when users need to create, modify, or validate Salesforce Validation Rules.