Activity Forums Salesforce® Discussions In which situation we should avoid using Future method in Salesforce?

  • chanchal kumar

    Member
    July 17, 2018 at 11:52 am

    hello shradha,

    Salesforce provides different ways to run your code asynchronously like Batch apex, @future method.

    there are some limitation of future method,

    • You cant call a future method from another future method.
    • You can call up to 50 @future methods per transaction.
    • You can call up to 250000 future methods per 24 hours. This is in conjunction with all types of asynchronous methods like batch apex.
    • @future methods are not executed during salesforce downtime and any already running jobs during the start of downtime are halted and restarted after the downtime.
  • shariq

    Member
    September 19, 2018 at 2:05 am

    Hi,

    Future Apex. - Future Apex is used to run processes in a separate thread, at a later time when system resources become available. Note: Technically, you use the @future annotation to identify methods that run asynchronously.

    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. You can also make use of future methods to isolate DML operations on different sObject types to prevent the mixed DML error. Each future method is queued and executes when system resources become available. That way, the execution of your code doesn’t have to wait for the completion of a long-running operation. A benefit of using future methods is that some governor limits are higher, such as SOQL query limits and heap size limits.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos