You need to sign in to do that
Don't have an account?
Roy J 6
@future method not working via after update trigger
Hi all i am working with future method functionality call the future class in after update trigger i control the recursive update too. future method is inside method i get one list and modify it then load one mater list finally update but i can't update i am getting error like this,
Error:first exception cannot_insert_update_activate_entity execution of afterupdate
Any Suggestion
Error:first exception cannot_insert_update_activate_entity execution of afterupdate
Any Suggestion
Greetings to you!
You should make sure this invocation is not made if the current context is already asynchronous (ie., either future or batch). Consider the following scenario. There is a trigger on Account object that invokes a future method as follows:
* makeCalloutFutureMethod is a future annotated method
Now, if an Account record is inserted through a batch process or through another future method, the above trigger would throw an exception saying "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AccountTrigger: execution of AfterInsert caused by: System.AsyncException: Future method cannot be called from a future or batch method". As the exception message indicates, a future method cannot be invoked from future or batch method execution context.
There is two possible workaround for this problem:
1. Update the trigger logic to leverage the System.isFuture() and System.isBatch() calls so that the future method invocation is not made if the current execution context is future or batch. Record created through such cases should be handled separately using a scheduled batch job or something similar. The above example can be updated as follows,
Replace the future method with Queueable Apex. Queueable Apex was introduced in Winter'15 and it is more powerful than future methods.
Please read the following articles to find more information about Queueable Apex:
http://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_queueing_jobs.htm
http://developer.salesforce.com/blogs/developer-relations/2015/05/queueable-apex-future.html
Reference: https://www.linkedin.com/pulse/considerations-invoking-future-method-from-trigger-andi-giri/
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas