# Run as User Future Method

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

1. Avoid using the Run as User in the process and let the user that kicks the process have access to create SDJobs.
2. 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.

{% hint style="info" %}
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.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/sdocs/maintenance-and-troubleshooting/legacy-workflows/s-doc-jobs-legacy/run-as-user-future-method.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
