salesforce_create_validation_rule
Create a validation rule on a Salesforce object to block invalid records by defining a formula and an error message displayed when the formula is true.
Instructions
Create a validation rule on a Salesforce object using the Tooling API. The rule evaluates an error condition formula and displays an error message when the formula returns true.
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": "salesforce_create_validation_rule"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| active | No | Whether the rule should be active after creation (default true) | |
| ruleName | Yes | API name for the validation rule (no spaces, e.g. 'Require_Phone_For_Hot_Leads') | |
| objectName | Yes | Salesforce object API name (e.g. 'Account', 'My_Object__c') | |
| description | No | Internal description of the rule's purpose | |
| errorMessage | Yes | Error message shown to users when validation fails (e.g. 'Phone is required for Hot leads') | |
| errorDisplayField | No | API name of the field where the error should appear. If omitted, the error appears at the top of the page. | |
| errorConditionFormula | Yes | Salesforce formula that evaluates to TRUE when the record should be invalid. Example: 'AND(Rating = "Hot", ISBLANK(Phone))' |