UTIL_ValidationRule.ValidationError
Class · Group: Validation
Learn it: Fast Start - Custom Validations and Validation guide
global class UTIL_ValidationRule.ValidationErrorRepresents a single validation error or warning.
Constructors
| Constructor | Description |
|---|---|
| global ValidationError(String ruleName, String message, String fieldName, String severity) | Builds an error outside shadow mode, so an error with Error severity blocks the save. |
ValidationError(String ruleName, String message, String fieldName, String severity)
global ValidationError(String ruleName, String message, String fieldName, String severity)Builds an error outside shadow mode, so an error with Error severity blocks the save. Set recordIndex, recordId, groupName and shadowMode on their fields after it is built.
Parameters
| Parameter | Type | Description |
|---|---|---|
ruleName | String | The rule DeveloperName |
message | String | The error message |
fieldName | String | The field API name (may be null) |
severity | String | The severity level |
Example
UTIL_ValidationRule.ValidationError instance = new UTIL_ValidationRule.ValidationError('myName', 'An error occurred', 'myName', 'Error');Fields
| Field | Description |
|---|---|
| global String fieldName | The field API name to display the error on (may be null for page-level). |
| global String groupName | The validation rule group DeveloperName. |
| global String message | The error message to display. |
| global Id recordId | The record ID (available except in before insert). |
| global Integer recordIndex | The record index in the trigger list (for before insert). |
| global String ruleName | The DeveloperName of the validation rule that failed. |
| global String severity | The severity ('Error' or 'Warning'). |
| global Boolean shadowMode | True when the rule that failed runs in shadow mode: watch-only, so the failure is logged but the save is not blocked, whatever the severity. |
fieldName
@AuraEnabled global String fieldNameType: String
The field API name to display the error on (may be null for page-level).
Example
String value = instance.fieldName;groupName
@AuraEnabled global String groupNameType: String
The validation rule group DeveloperName.
Example
String value = instance.groupName;message
@AuraEnabled global String messageType: String
The error message to display.
Example
String value = instance.message;recordId
@AuraEnabled global Id recordIdType: Id
The record ID (available except in before insert).
Example
Id value = instance.recordId;recordIndex
@AuraEnabled global Integer recordIndexType: Integer
The record index in the trigger list (for before insert).
Example
Integer value = instance.recordIndex;ruleName
@AuraEnabled global String ruleNameType: String
The DeveloperName of the validation rule that failed.
Example
String value = instance.ruleName;severity
@AuraEnabled global String severityType: String
The severity ('Error' or 'Warning').
Example
String value = instance.severity;shadowMode
@AuraEnabled global Boolean shadowModeType: Boolean
True when the rule that failed runs in shadow mode: watch-only, so the failure is logged but the save is not blocked, whatever the severity. It is copied from the rule's Shadow Mode setting, and is false when the error is built with the constructor.
Example
Boolean value = instance.shadowMode;