generating-validation-rule

Generate Salesforce ValidationRule metadata with errorConditionFormula and errorMessage.

803|289|Updated Nov 7, 2025
One-click install
npx skills add https://github.com/forcedotcom/sf-skills --skill generating-validation-rule-forcedotcom
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generating-validation-rule
Source: https://github.com/forcedotcom/sf-skills/tree/main/skills/generating-validation-rule
Command: npx skills add https://github.com/forcedotcom/sf-skills --skill generating-validation-rule-forcedotcom

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Salesforce validation rules can be hard to author correctly when you need reliable enforcement of business logic, clear error messaging, and correct formula behavior across field types.

Core Features & Use Cases

  • Validation Rule Authoring & Updates: Generates or updates validation rule metadata and formulas for when records should fail on save, with guidance for common formula mistakes.
  • Data Quality Enforcement: Applies to scenarios like preventing invalid inputs, validating required fields, and enforcing cross-field business constraints at the data layer.
  • Deployment & Troubleshooting Support: Helps resolve common deployment and metadata formatting issues, including formula XML/CDATA handling and correct file extension usage.

Quick Start

Use this skill to generate a Salesforce validation rule that blocks saving a record when a field fails a specified business condition and returns a user-friendly error message.

Frequently Asked Questions about generating-validation-rule

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Salesforce validation rule that blocks invalid data on save?

To create a Salesforce validation rule, define an errorConditionFormula that evaluates to TRUE when data fails business logic constraints, then specify a user-friendly errorMessage. This ensures record-level data quality enforcement during save operations.

Why does my Salesforce validation rule formula fail deployment due to XML formatting errors?

Salesforce validation rule deployment fails when XML-containing formulas lack correct CDATA wrapping in the metadata XML. Proper formatting requires wrapping complex formulas in CDATA tags and using the .validationRule-meta.xml file extension for successful deployment troubleshooting.

What is the correct TRUE/FALSE logic for Salesforce validation rules?

Salesforce validation rules trigger when the errorConditionFormula returns TRUE, meaning the record fails the specified business condition. Correct TRUE/FALSE logic prevents invalid inputs and enforces cross-field business constraints at the data layer during save operations.

How do I enforce cross-field business constraints in Salesforce metadata?

Enforce cross-field business constraints in Salesforce by generating a validation rule with an errorConditionFormula that evaluates field relationships across the record. This metadata enforces data quality by blocking saves when fields violate specified business logic constraints.

Can I update an existing Salesforce validation rule's error message and active status?

Yes, you can update existing Salesforce validation rule metadata to modify the errorMessage and handle active status toggling. This allows ongoing deployment troubleshooting and refinement of data quality enforcement without recreating the entire rule.

What are the limitations of Salesforce validation rules for deployment troubleshooting?

Salesforce validation rules are limited by metadata XML constraints, requiring correct CDATA wrapping for formulas containing XML characters and strict .validationRule-meta.xml file formatting. Formula correctness and naming conventions must be satisfied to avoid deployment failures.