Let’s understand, What is a Future class in salesforce is and its importance.
- The future class is used for long-running operations, It will run in the background.
- It is an Asynchronous.
- It will run the Process in a separate thread when the resource is available.
- We can define the Future class with @future annotation.
Syntax :
global class SruviFuture
{
@future
public static void sruviMethos()
{
// Perform some operations
}
}
Points to remember about Future Class :
- The future method must be a static method.
- The future method always returns void.
- The future method can’t take sObjects or objects as arguments.
- we can avoid mixed DML exceptions using Future Class.
- A future method can’t invoke another future method.
- future class run in System mode.
Future Class Limitations :
- The maximum number of future method invocations per a 24-hour period is 250,000
- You can’t call a future method from a future method.
- The getContent() and getContentAsPDF() methods can’t be used in methods with the @future annotation.
- You’re limited to 50 future calls per Apex invocation.
- The maximum number of future method invocations per 24-hour period is 250,000.
- A common pattern is to pass the method a List of record IDs that you want to process asynchronously.
Learn a few more interesting points about future class.
Disadvantages of Future Class : Click Here
Where / When to use Future Class: Click Here
