I am calling an Apex Future method from Process builder. This is working fine when the Process Builder condition is "only when a record is created". But when I change the condition to "when a record is created or edited" it is throwing an error saying "Future method cannot be called from a future or batch method.......". Is there anything I missed here?
-
2Can you post the code for your invocable action and future method? It's obvious, but if your future method updates the same record that the PB is running on then it will lead to a future method being called from a future context– AidanNov 29, 2017 at 13:20
-
1Try creating a self contained example that other people would be able to run on a sandbox - I know I'd like to take a look at this, but without some of the details, its difficult to recreate the issue.– battery.cordNov 29, 2017 at 14:20
-
@Aidan - Good catch. If you can post your comment as an answer, I will mark it as the answer to the Question.– Saroj BeraNov 29, 2017 at 17:52
-
@battery.cord - Thanks for the suggestion, I will add some more details to the Question.– Saroj BeraNov 29, 2017 at 17:57
2 Answers
Thanks Saroj, didn't think it would be that easy! Copied from my comment because this turned out to be the answer:
It's obvious, but if your future method updates the same record that the PB is running on then it will lead to a future method being called from a future context
I modified my PB so that the decision diamond makes sure that the field being updated is null. That may not work in your case, understandably.