+ Start a Discussion
arti rathodarti rathod 

how to handle 500000 records of Account, If you have 500K accounts, which you are updating through batch, and you have trigger on account which is having the future method. So will that work? What changes should be done to avoid future here?

Best Answer chosen by arti rathod
Abhishek BansalAbhishek Bansal
Hi Arti,

It is not allowed to call the future method from the Batch Apex, if you still want to call it then you need to write a web service which can call the futire method. Complete steps are given below:
https://www.pebibits.com/future-method-asynchronous-apex/

If you simply want to avoid this, create a static variable and set it to false from Batch class. Now add a check in your trigger where the future method is called so that it will only call the future method if the variable is true.

Let me know if you need more information on this.

Thanks,
Abhishek Bansal.

All Answers

AbhishekAbhishek (Salesforce Developers) 
Hi,

Try the suggestions as mentioned in the developer blog,

https://salesforce.stackexchange.com/questions/27462/can-salesforce-handle-50-or-70-million-records

For further reference, you can check this too,

https://developer.salesforce.com/forums/?id=906F000000090EEIAY

I hope you find the above information is helpful. If it does, please mark as Best Answer to help others too.

Thanks.
Abhishek BansalAbhishek Bansal
Hi Arti,

It is not allowed to call the future method from the Batch Apex, if you still want to call it then you need to write a web service which can call the futire method. Complete steps are given below:
https://www.pebibits.com/future-method-asynchronous-apex/

If you simply want to avoid this, create a static variable and set it to false from Batch class. Now add a check in your trigger where the future method is called so that it will only call the future method if the variable is true.

Let me know if you need more information on this.

Thanks,
Abhishek Bansal.
This was selected as the best answer