You can call a future method
DML operations on certain sObjects, sometimes referred to as setup objects, can’t be mixed with DML on other sObjects in the same transaction. You must insert or update these types of sObjects in a different transaction to prevent operations from happening with incorrect access-level permissions. For example, you can’t update an account and a user role in a single transaction. However, deleting a DML operation has no restrictions.
Methods with the future annotation must be static methods, and can only return a void type. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types.
Methods with the future annotation have the following limits:
How methods with future annotation can take sObjects or objects as arguments?
https://developer.salesforce.com/blogs/developer-relations/2013/06/passing-objects-to-future-annotated-methods.html
How to call a future method from a batch class?
https://salesforce.stackexchange.com/questions/24843/calling-future-method-from-batch
- 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.
- to isolate DML operations on different sObject types to prevent the mixed DML error.
- for taking advantage of higher governor limits
DML operations on certain sObjects, sometimes referred to as setup objects, can’t be mixed with DML on other sObjects in the same transaction. You must insert or update these types of sObjects in a different transaction to prevent operations from happening with incorrect access-level permissions. For example, you can’t update an account and a user role in a single transaction. However, deleting a DML operation has no restrictions.
Methods with the future annotation must be static methods, and can only return a void type. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types.
global class FutureMethodRecordProcessing {
@future
public static void processRecords(List<ID> recordIds) {
List<Account> accts = [SELECT Name FROM Account WHERE Id IN :recordIds];
// Process records
}
}
Methods with the future annotation have the following limits:
- No more than 50 method calls per Apex invocation
- The maximum number of future method invocations per a 24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater.
How methods with future annotation can take sObjects or objects as arguments?
https://developer.salesforce.com/blogs/developer-relations/2013/06/passing-objects-to-future-annotated-methods.html
How to call a future method from a batch class?
https://salesforce.stackexchange.com/questions/24843/calling-future-method-from-batch
0 comments:
Post a Comment