Future Methods – @future in salesforce Apex

What is Future Methods –

A future method runs asynchronously in background. You can use future method if you have long-running operations(callouts to external Web services or any operation that runs in its own thread and time. Also you can used for isolated DML operations. Each future method is queued and executes when system resources become available. Your program doesn’t have to wait for the completion of a future methods call.

Rules:
Methods with the future annotation must be static methods
Only return a void type
Cannot take sObjects or objects as arguments

If you want to pass sObjects that already exist in the database, pass the sObject ID or IDs and use the ID to perform a query in DB inside the future methods.

 

 

Gopal Das
Follow me

Gopal Das

Founder at GopalDas.Org
He is a technology evangelist, Salesforce trainer, blogger, and working as a Salesforce Technical Lead. After working in Java based project implementation, he jumped to the Salesforce system on a whim and never looked back. He fell in love with Salesforce’s flexibility, scalability, and power. He expanded his knowledge of the platform and became a Certified App Builder, Administrator, Platform Developer I, SalesCloud Consultant while leading the Salesforce implementation and technology needs. He has worked in a wide variety of applications/services like desktop, web and mobile applications.
Gopal Das
Follow me

Leave a Reply

Your email address will not be published. Required fields are marked *