Skip to main content
2 of 2
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/

You can add an error to a specific field using the addError method as follows:

SObject someRecord;
someRecord.SomeField__c.addError('Custom Message');
//or
someRecord.someField__c.addError(someException);

Note that you cannot add it to a field dynamically. This error mapping can only be done with a hard-coded field. See also:

Adrian Larson
  • 151.4k
  • 38
  • 247
  • 431