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

Update field when DML operation fails

Can we update any field  through trigger if insertion of record fails?
I kept an error when a record with duplicate email exists through adderror in when a duplicate lead is creating it will prevent with error.At the same time I want to update a field in already existing lead.How can I achieve this?
Chidambar ReddyChidambar Reddy
Hi sunny 
We can achieve this if you provide the code in detail
1. we can either use an if condition 
2. We can call a method before firing the trigger.addError

It would be good if you provide the code

Thank you