+ Start a Discussion
Ankit Singh 6Ankit Singh 6 

Getting error while creating task through Apex in Salesforce

We are getting following error while creating a task in Salesforce.
Error msg: Too many retries of batch save in the presence of Apex triggers with failures: when triggers are present partial save requires that some subset of rows save without any errors in order to avoid inconsistent side effects from those triggers. Number of retries: 2 
We are getting this error on calling SforceService.create() function.

Please let me know the solution for this.
Grazitti TeamGrazitti Team
Hi Ankit,

This indicates that there were too many failures in the code executed.
In order to avoid this error, you may have to reduce the batch size.

More information in this link:

Grazitti Team
Web: www.grazitti.com
Email: sfdc@grazitti.com
Yogesh KulkarniYogesh Kulkarni
Hi Ankit,

This is records insert error. Can you provide your code so that the errors can be pointed out.

Ankit Singh 6Ankit Singh 6

The issue is occurring for few leads only, for other leads it is successfully creating task in Salesforce. Also we have provided the batch limit of upto 200 records for single create call.
Bhawani SharmaBhawani Sharma
May be you some some trigger(s) in place which is running when you are creating/updating the records from batch. If you really don't need to run the trigger while updating data from batch, you can use some static flag to bypass the trigger.
Ankit Singh 6Ankit Singh 6
Hi Bhawani

If there is some trigger running then it should affect task creation for all leads, but here our system sends bulk creation(200 at time) of task and few of them (not all) getting failed with the error specified above.