You need to sign in to do that
Don't have an account?
Gabriel Dias
Update record not working when I addError in a trigger
I have a trigger that checks if exists a duplicate record before insert a Lead and when it find a duplicate record I need to update two fields on this record with the date of the try to insert a duplicate record and a boolean that shows if you hear an attempt to register for the lead, but when I use AddError the other record is not saved in the database.
Does anyone have a workaround to this problem? Future methods also don't work.
Does anyone have a workaround to this problem? Future methods also don't work.
Try using the variable instead of trigger context directly to addError. Eg: Instead of using " trigger.new[0].addError('Some error') "" bring the record to a variable like
for (<object name> a : Trigger.new) {
<your logic>
a.addError(error message);
}
Hope this helps!