Run as User Future Method
PreviousManaging and Resolving Too Many Queueable Jobs Errors in SalesforceNextHigh Assurance with MFA Error
Last updated
Was this helpful?
Problem
A common error that will come up at times when working with automation is “System.AsyncException: Future method cannot be called from a future or batch method”. Clients will often create SDJobs by using custom apex that is set up as a future method (Or something like our own batch apex solution). While this is no problem itself, if a client tries to use the Run as User functionality in one of these future methods, it will create the error mentioned above as the Run as User function is also a future method.
Solution
There are two likely things to do when you see this problem
Avoid using the Run as User in the process and let the user that kicks the process have access to create SDJobs.
Break the process in to multiple parts (Such as an apex trigger for part, and then a flow) and call Run as User in a flow or other non future method.
Highlight important information in a panel like this one. To edit this panel's color or style, select one of the options in the menu.
Last updated
Was this helpful?
Was this helpful?

