Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

Has anyone found a way of adding a dynamic field level error to an sobject?

I would like to do something like

mySobjectRec.get('fieldname').addError('my error message');

I realise that mySobjectRec.fieldname__c.addError('my error message') works.

1 Answer

0 votes
by (32.1k points)
edited by

Unluckily, this is not possible to do. 

The addError methods on SObject use a highly specialized way to reference the field which is used to hard code the field reference ahead of the method.

Want to learn about Salesforce in depth? Enroll in this Salesforce course provided by Intellipaat.
 

Browse Categories

...