Activity Forums Salesforce® Discussions Why Salesforce Future Methods returns only void type?

  • madhulika shah

    Member
    July 3, 2018 at 1:24 pm

    Future Methods return void type because it is an asynchronous process.

  • Parul

    Member
    September 15, 2018 at 6:45 am

    Because it is asynchronous process.. For example if you run future method from synchronous process then you can't wait to complete asynchronous process and get that value from asynchronous process in trigger context.

     

    Thanks

  • shariq

    Member
    September 15, 2018 at 9:05 pm

    Hi,

    The @future methods can only have primitive data types (or collections of them) for their input parameters. As they run at a future time from when they are called, they have nowhere to return a response and thus can only return a void type. Other than this and the fact that there is a limit as to how many future methods can be invoked at any one time, they look and behave like any other method.

    Future methods will run in the future. You don't want your synchronous code waiting an unknown period of time for an asynchronous bit of code to finish working.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos