You need to sign in to do that
Don't have an account?
VT878
Error Message and Validation Rule
Hi friend,
I have two asks for you.
1) Is possible use a Error Message of a Validation Field as label?
In other words, I have two validation rules with different error messages and in a Apex class I want use their Error Message as I use Custom Label with 'Label' key word.
2) When a Validation Rule is true and a DML statement fail, is possible take from DML Exception object how is the Validation Rule which is true?
I post these questions because I have differente Validation Rule and each of these has a different Error Message, and in a Contoller I must do different operations for each Validation Rule, and now the only solution that I can use is hard coding, for example:
if (ex.getMessage == 'Error Message1')
{...}
else if (ex.getMessage == 'Error Message2'))
{...}
I have two asks for you.
1) Is possible use a Error Message of a Validation Field as label?
In other words, I have two validation rules with different error messages and in a Apex class I want use their Error Message as I use Custom Label with 'Label' key word.
2) When a Validation Rule is true and a DML statement fail, is possible take from DML Exception object how is the Validation Rule which is true?
I post these questions because I have differente Validation Rule and each of these has a different Error Message, and in a Contoller I must do different operations for each Validation Rule, and now the only solution that I can use is hard coding, for example:
if (ex.getMessage == 'Error Message1')
{...}
else if (ex.getMessage == 'Error Message2'))
{...}
VineetKumar
- Using the MetaData API you can fetch the details of a validation rule by querying the ValidationRule object.
- You can only get if the error was a result of some validation. You cannot get the name of the particular validation that caused the error.