FLOW_ExecuteValidationRules
Class · Group: Validation
global inherited sharing class FLOW_ExecuteValidationRulesFlow invocable action to execute validation rules against records. Use this in Record-Triggered Flows or Screen Flows to validate records before DML and display user-friendly error messages. Usage in Screen Flow (Pre-DML Validation): User fills in fields on a screen Before "Create Records" element, add "Action" element Call this invocable with the record(s) to validate Check HasErrors output - if true, display errors and loop back to edit screen If false, proceed to Create Records
Since: 1.0
Example:
// Flow Configuration: Action: Execute Validation Rules Input: Records: {!$Record} or collection TriggerContext: BEFORE_INSERT OldRecords: (leave empty for insert; use {!$Record__Prior} for update) Output: HasErrors: Boolean - check in Decision element HasWarnings: Boolean - check for non-blocking warnings Errors: List<DTO_FlowValidationError> - display in lwcValidationErrors component Warnings: List<DTO_FlowValidationError> - display shadow mode or warning-severity results ErrorMessage: String - concatenated message for simple display
See Also: UTIL_ValidationRule, FLOW_BypassValidation
Methods
| Method | Description |
|---|---|
| global static List execute(List<FLOW_ExecuteValidationRules.DTO_Request> requests) | Executes validation rules against the provided records. |
Inner Classes
| Class | Description |
|---|---|
| DTO_Request | Request DTO for the Execute Validation Rules invocable action. |
| DTO_Response | Response DTO for the Execute Validation Rules invocable action. |
Method Details
execute
@InvocableMethod(category='Validation' description='Validates records against formula-driven validation rules. Returns errors/warnings without blocking save.' label='Execute Validation Rules') global static List<FLOW_ExecuteValidationRules.DTO_Response> execute(List<FLOW_ExecuteValidationRules.DTO_Request> requests)Executes validation rules against the provided records.
Parameters:
requests(List) - List of validation requests (typically just one from Flow)
Returns: FLOW_ExecuteValidationRules.DTO_Response - List of validation responses with errors and warnings
Since: 1.0
Example:
// Programmatic usage example
FLOW_ExecuteValidationRules.DTO_Request request = new FLOW_ExecuteValidationRules.DTO_Request();
request.records = new List<SObject>{account};
request.triggerContext = 'BEFORE_INSERT';
List<FLOW_ExecuteValidationRules.DTO_Response> responses =
FLOW_ExecuteValidationRules.execute(new List<FLOW_ExecuteValidationRules.DTO_Request>{request});
if(responses[0].hasErrors)
{
// Handle validation errors
}