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

addError method issue

I have written this code block,
trigger Firm_LOB_Check on Fund__c (before insert, before update) {
for (Fund__c lfund : {
Firm__c f  = [select Line_Of_Business__c FROM Firm__c where Id = :lfund.Firm__c];
I get the below mentioned error message when the trigger gets fired. If anyone got an idea please share.
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Firm_LOB_Check3 caused an unexpected exception, contact your administrator: Firm_LOB_Check3: execution of BeforeInsert caused by: System.Exception: SObject row does not allow errors: Trigger.Firm_LOB_Check3: line 10, column 1
Your trigger is acting on Fund__c, which would be in response to a user inserting or updating a Fund record.  But you're adding the error to "f", which is a Firm__c object.  The error message is telling you that you cannot add an error to that record -- the reason is, the user would never see it, because it's not the field they're modifying.
Thanks I got it later, its working fine now.