You need to sign in to do that
Don't have an account?
Pseudodarwinist
@ future method errors and governor limits related to future methods
I would like to understand practical examples of @future annotated methods and also the limitations of future methods (governor limits).Can somebody help me by providing practical code examples and scenarios where i will receive errors from their org specific experiences.In what scenarios i will not be able to call @future from @Future(in what circumstances can i require the need to call a future method within a future method or from the batch class).Please help me by poiniting to a right blog or provide certain practical scenarios ?
Use Case: I am trying to call @future method from trigger and got CANNOT_INSERT_UPDATE_ACTIVATE_ENTITYError, because of update operation within the @future method.
The basic example of the pattern I'm talking about is this Using this class is pretty straightforward, you'd replace your direct call to the @future method with
SaferFurure.execute(someIdList);
With that out of the way, we can turn attention to removing the @future call from inside a loop.
Given your provided trigger, it appears that you might not want to call your @future method with every record being inserted. I also doubt that you want to be repeatedly calling your @future method with the same data multiple times (which is a very likely possibility with the trigger that you currently have).
Instead, making your trigger bulk-friendly would involve first preparing the data that you want to send to your @future method, and, in a separate section of trigger code, then calling your @futuremethod.
An example based provided trigger for the same:
The above example resolves both callout and governors limit problems.
For more information please check with below links.
- https://webkul.com/blog/future-annotation-salesforce/
- https://salesforce.stackexchange.com/questions/75779/future-method-calling-another-future-method
Hope this helps.Kindly mark this as solved if the reply was helpful.
Thanks,
Nagendra