You need to sign in to do that
Don't have an account?
.addError - SObject row does not allow errors
I've tried several variations of this with no luck. My guess is that I'm implementing .adderror incorrectly. I get this error:
SObject row does not allow errors Class.IdeaSolution.ideaIdToCase: line 176, column 6 Trigger.IdeaAfterUpdateAfterInsert: line 4, column 2: Class.IdeaSolution.ideaFromSolution: line 83, column 6
List<case> updateCases = New List<case>();
Case[] c = [select Idea__c,CaseNumber from case where id in :caseSolutionMap.keyset()];
for (Integer i = 0; i < c.size(); i++)
{
if (c[i].Idea__c != Null)
{
c[i].addError('There is already an idea associated with case ' + c[i].CaseNumber + '. This must be resolved before continuing.');
}
else
{
c[i].Idea__c = solutionIdeaMap.get(caseSolutionMap.get(c[i].id));
updateCases.add(c[i]);
}
}
update updateCases;
Looks like you are trying to add the error to an element you are querying for. I believe the only thing you could add the error to in trigger, is the elements the trigger is fired on ( something from your Trigger.new for example).