+ Start a Discussion
siva@shiva.comsiva@shiva.com 

Too many retries of batch save in the presence of Apex triggers with failures

siva@shiva.comsiva@shiva.com
i did not understand what is that ......
please help out of this issue its very urgent..
see i have some 100000 records so.. i am trying to update those records.


i will explain my case
while adding campaign members into campaign .....i am updating campaign details into  lead and contact ( campaignmembers)
recently two fields made as mandary on lead as well as contact  so i need to through an error like enter mandatory fields then only lead or contact will update.
for that i wrote trigger ..it is working on single records but not on bulk records ..



logontokartiklogontokartik
Please post your trigger 
Bhawani SharmaBhawani Sharma
Error is related to your code is trying to retrying the save operation each time when it's failing. Do you performing any operation on the same record? Reason I am saying is, 100000 is not bit count for batch. If your batch size is 200, then it will create 500 packets, that's notmuch data.
Make sure your trigger is written properly to handle the bulk cases.
logontokartiklogontokartik
Your trigger doesnt make any sense to me, irrespective of any number of campaignmembers you insert/update, if one (or first ) lead has error, it would fail all the campaign members which is why you are getting the error.  

trigger.new[0].addError is whats causing the issue. Also i dont know why you have a DML Exception in the catch, without not doing any DML operation(there are no inserts, updates in your trigger). 

I would suggest you to take some time looking at your trigger, understand it, optimize it property and it should resolve your issues. Let me know if I can be of any more help. 

Bhawani SharmaBhawani Sharma
And do you have trigger also on the same object? Regards, Bhavi Sharma Certified Salesforce Consultant bhavi@simplyforce.com/bhawani.sh.sharma@gmail.com +91-9928130589 LinkedIn | Twitter | Blog | Community www.simplyforce.com
siva@shiva.comsiva@shiva.com
yes i have