You need to sign in to do that
Don't have an account?

Is there any point using an @future method for DML operations?
I have inherited a lot of old code which uses @future methods for doing DML operations. Is there any benefit to doing this? The only thing I can think of is in case there are a lot of records to be updated but I thought @future methods were only really used for callouts.
You are correct about the future methods being used for callouts, but they are also very useful for DML operations especially when you get caught in "Mixed DML Operation" error.
Mixed DML Operation error is thrown when you try to insert/update setup and non-setup objects in the same transaction. Hence, using @future method can help you out here, since the operations performed inside this method will be treated as a separate transaction which will be executed asynchronously.
This article will give you indepth knowledge about it:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_non_mix_sobjects.htm
Please mark this answer as solved if it answers your query.
Thanks,
Adheesh
You can also use future methods to isolate DML operations on different SObject types to prevent the mixed DML error.
Refer below links :
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm#!
https://amitsalesforce.blogspot.com/2015/02/future-methods-in-salesforce.html
Thanks
Chathura
What is Future Method:
A future method runs in the background, asynchronously. You can call a future method for executing long-running operations, such as callouts to external Web services or any operation you'd like to run in its own thread, on its own time.
When to use Future Method:
If you want to make the execution of the apex program to run asynchronously then we make use of future method.When you specify
future , the method executes when Salesforce has available resources. For example, you can use the future annotation when making an asynchronous Web service callout to an external service.
Apex class with Future Method
Test Class for the above:
For more Info please refer bellow Link:
http://amitsalesforce.blogspot.sg/2015/02/future-methods-in-salesforce.html
Best Regards,
Dushyant Srivastava