+ Start a Discussion
AsokAsok 

System.AsyncException: Future method cannot be called from a future method: cloudswarm.

Dear All,

 

I have cloudswarm installed last week. After that, I noticed one of my batch code failed with the below error message.

 

Update failed. First exception on row 0 with id 00k3000000GhuidAAB; first error: CANNOT_INSERT_UPDATE_ACTIVATE_

ENTITY, cloudswarm.opptySwarm: execution of AfterUpdate

caused by: System.AsyncException: Future method cannot be called from a future method: cloudswarm.SwarmHelper.evaluateOpptyRules(LIST<Id>)

(cloudswarm): []
Kindly help me in fixing the issue.



The Cloud Swarm TeamThe Cloud Swarm Team

It looks like you're having this issue because the Cloud Swarm trigger runs, then another trigger set up is making a change to the record which calls the Cloud Swarm trigger again, etc., recursively.

 

See this article on how to prevent recursive future method calls:

 

http://blog.jeffdouglas.com/2009/10/02/preventing-recursive-future-method-calls-in-salesforce/

 

~ The Cloud Swarm Team

DevNVDevNV

I'm having the same problem with Cloud Swarm, but I think it is because I have another process that calls a future method that updates an Opportunity.  Here is the error message in my future method code:

 

Update failed. First exception on row 0 with id 006P0000003PCl3IAG; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, cloudswarm.opptySwarm: execution of AfterUpdate

caused by: System.AsyncException: Future method cannot be called from a future or batch

 From what I can determine, I have a Quote trigger that is calling a future method to update the related Opportunities.  it looks like Cloud swarm has an after update trigger to determine if the Opportunity meets any rules and if so, calls a future method to do something with the follows. 

 

If that is true, does this mean using CloudSwarm for Opportunities prevent me from running any async opportunity updates?  Seems like a big limitation if that is true.

The Cloud Swarm TeamThe Cloud Swarm Team

Hi DevNV,

 

You can make Cloud Swarm a synchronous method by removing the @future annotation on the class in the Unmanaged version.  That should provide a workaround for your issue with it being called by another asynchronous method.

 

~ The Cloud Swarm Team

DevNVDevNV

Thanks for your quick response.  If we are already using the Managed Package - do we need to uninstall first, and will we lose all the data/settings/rules in that process?

The Cloud Swarm TeamThe Cloud Swarm Team

That's correct.  With Enterprise or Unlimited Edition can use the Data Loader to Export your rules, uninstall the Managed package, install the Unmanaged pacakge, and re-Import the rules with the Data Loader.  If you haven't got a lot of settings, it might just be easier to manually re-enter them instead of the export/import.

 

~ The Cloud Swarm Team