+ Start a Discussion
ajaykekaajaykeka 

How to display the Error Messages in Filed level using Triggers?

Hi all,

 

How to display the Error Messages in Filed level using Triggers?

 

Can you please Help Me...

 

Thanks for your help

Best Answer chosen by Admin (Salesforce Developers) 
SeAlVaSeAlVa

By calling to .addError() method on the field you want.

 

Example:

trigger.new[0].Name.addError('Name field does not match the pattern expected'); 
// where Name is the field, if you want to use custom fields remember to concatenate '__c'.
// Note, this is just an example and it is NOT bulk friendly.

 

Regards