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
AneeshaAneesha 

Trigger.new[0].addError giving Insufficient Privileges error

Hi All,

I am getting Insufficient Privileges error while adding error messgae using addError. I have tried with System Admin profile but still the same issue.
The code works fine when I comment out the addError lines.

Does anyone know why this issue is happening?
Best Answer chosen by Aneesha
Ramu_SFDCRamu_SFDC
Try mentioning the field name rather than mentioning it directly on the record. 

Eg : Trigger.new[0].myField__C.addError('bad');

Review the belwo code for more information on add error method and usage

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject.htm

Please mark this as the best answer if it resolved your query so that It would help others looking for similar solutions .

All Answers

Gupta.VishalGupta.Vishal
can you post your trigger, to have a look ?
Ramu_SFDCRamu_SFDC
Try mentioning the field name rather than mentioning it directly on the record. 

Eg : Trigger.new[0].myField__C.addError('bad');

Review the belwo code for more information on add error method and usage

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_sobject.htm

Please mark this as the best answer if it resolved your query so that It would help others looking for similar solutions .
This was selected as the best answer