Create Salesforce Validation Rule
sf_create_validation_ruleCreate or update Salesforce validation rules to enforce data quality. Define an error formula and message to block invalid records on any object.
Instructions
Creates or updates a Salesforce Validation Rule on any object via the Metadata API. The errorConditionFormula returns TRUE when data is INVALID. Use for data quality enforcement.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"objectName": "<objectName>",
"ruleName": "<ruleName>",
"errorConditionFormula": "<errorConditionFormula>",
"errorMessage": "<errorMessage>"
},
"name": "sf_create_validation_rule"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| active | No | Whether the rule is active | |
| ruleName | Yes | API name for the rule, e.g. 'Require_Close_Date' | |
| objectName | Yes | Object API name, e.g. 'Account', 'Opportunity', 'Invoice__c' | |
| description | No | Description of this validation rule | |
| errorMessage | Yes | Error shown to user when validation fails (max 255 chars) | |
| errorDisplayField | No | Field API name to display error next to, e.g. 'CloseDate'. Blank = top of page. | |
| errorConditionFormula | Yes | Formula returning TRUE when data is INVALID, e.g. "AND(ISPICKVAL(StageName,'Closed Won'),ISBLANK(CloseDate))" |