Activity Forums Salesforce® Discussions Why sObjects can’t be passed as arguments to future methods in Salesforce?

  • Why sObjects can’t be passed as arguments to future methods in Salesforce?

    Posted by Aditya on January 22, 2020 at 12:35 pm

    Why sObjects can’t be passed as arguments to future methods?

    • This discussion was modified 4 years, 2 months ago by  Aditya.
    Sumit replied 4 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Sumit

    Member
    January 22, 2020 at 12:37 pm

    The sObject might change between the time you call the method and the time it executes. In this case, the future method will get the old sObject values and might overwrite them. To work with sObjects that already exist in the database, pass the sObject ID instead (or collection of IDs) and use the ID to perform a query for the most up-to-date record. The following example shows how to do so with a list of IDs.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos