AllorNone inside Before insert Trigger - Duplicate Checking
Can someone explain to me in very simple how the AllorNone works in a before insert trigger?I was under the assumption that AllorNone is default false. I have a before insert trigger that checks for duplicates and uses addError() to prevent save. Test class fails in this scenario, insert 1 record -> insert list with one good, one duplicate.Is AllorNone not default false in a trigger? If not, any ideas on allowing partial save in a before insert trigger?
AllOrNone is set by the caller, not the trigger itself. When you use DmlOptions, the default is false. When you use the single parameter database methods or the inline DML statements, the default is true. So, to allow partial success in Apex Code, you normally do this: Database.insert(records, false);