All About Future methods
What are future methods ? Ans : 1. Methods used when you want to run apex transaction asynchronously 2. Static methods with @future annotation and void return type 3. Accepts only primitive types as arguments 4. Only 50 future calls are allowed per apex invocation 5. You can not call one future method from another future method When we generally use future methods? Ans: 1. When you want to make callouts to external web service in trigger 2. When you want to make callout after DML operation 3. When process needs to run in their own thread for processing records or complex calculaions 4. Isolating DML operations on different SObjects types to prevent mixed DML error . When we try to insert set up and Non set up object at a time we come across mixed DML exception. Why we can not pass Sobjects to future methods? Ans: The reason why objects can’t be passed as arguments to future methods is because the object can change between the time you call the method and the time that it actually exec