Website Loading ....

Future Class in Salesforce

2 min read

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 :

  1. The future method must be a static method.
  2. The future method always returns void.
  3. The future method can’t take sObjects or objects as arguments.
  4. we can avoid mixed DML exceptions using Future Class.
  5. A future method can’t invoke another future method.
  6. future class run in System mode.

Future Class Limitations :

  1. The maximum number of future method invocations per a 24-hour period is 250,000
  2. You can’t call a future method from a future method.
  3. The getContent() and getContentAsPDF() methods can’t be used in methods with the @future annotation.
  4. You’re limited to 50 future calls per Apex invocation.
  5. The maximum number of future method invocations per 24-hour period is 250,000.
  6. 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

 

Sruvi IT

Sruvi IT Solutions

Expert in digital transformation, SEO, and enterprise technology. Helping businesses grow through innovative IT solutions since 2018.