Future method cannot be called from a future or batch method

On This Page

Description

This error is caused by a future Apex method in your org being called from within a Kubaru batch Apex job. This would either be from 1) code that was locally developed in your org, or 2) code contained in a different managed package in your org. 

Kubaru assigns records asynchronously in a recurring batch Apex job. It also uses other batch Apex jobs for related functions such as syncing members to routers. Salesforce does not allow for @future Apex methods to be called from within a batch context, so if your customizations are attempting to do so (e.g. when a record is assigned) this error will occur. 

Resolution

If this is based on locally-developed code, the solution is to rework the logic so as to prevent this future call from being made from within the context of Kubaru’s batch job. If this is based on code from another managed package, we will need to work with that package’s support team to identify a solution.

You might consider using Trigger-Based Assignment in order to work around exclusively having to rely on the batch assignment job. However, we strongly suggest against this being relied on as the standard approach, chiefly because trigger-based assignment can only operate against records if they are assigned to your connected queue in a one by one manner. If a batch of records (i.e. 2 or more) is assigned to a connected queue at a time, then trigger-based assignment will not pick them up and they will need to rely on the batch job after the fact. If and when this happens, you will see the error all over again.

Was this article helpful?

On This Page