You need to sign in to do that
Don't have an account?
Am I in a @future method?
We are experiencing difficulty re-using code which involves @future methods. If a method is not marked @future and does DML it cannot be called before a callout. If we mark it as @future it cannot be called from some other @future method. We end up duplicating methods and having pairs of doThis() and doThis_future() or with optional boolean useFuture parameters. Is there a better way?
Example:
@future
public static void method1() {
// Do some future async DML
}
// method1() can be called before callouts
// method1() cannot be called from other @future methods
// nor anywhere in a chain starting with a @future method
I usually use dispatch functions in order to provide a seamless interface. For example:
You could also choose to use a boolean parameter or some other logic. The functions are private so they can only be called through the dispatch function.
Hope this helps.