function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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