Future method cannot be called from a future or batch method(Future method cannot be called from a future or batch method)

我们知道future方法在batch或者future方法中被调用,会报如下的错误:caused by: System.AsyncException: Future method cannot be called from a future or batch method.

但有时候,因为batch触发了trigger,而trigger调用了future,也会出现同样的错误。

那如何解决呢?

有一种思路就是用Salesforce提供的Platform Event.

————————

我们知道future方法在batch或者future方法中被调用,会报如下的错误:caused by: System.AsyncException: Future method cannot be called from a future or batch method.

But sometimes, because batch triggers trigger and trigger calls future, the same error will occur.

So how to solve it?

One idea is to use the platform event provided by salesforce