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
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:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_bulk_exceptions.htm

--
Regards,
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.

Thanks,
Yogesh
Ankit Singh 6Ankit Singh 6
Hi

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.