You need to sign in to do that
Don't have an account?
Insert a static global variable from @future method
I have a class, called from a trigger which fills a private static List variable declared at the class level. At the end of the class a @future method is called who'se only line is to insert the List. ApexJobs lists it as completed but in the debug logs i can't actually see the insert call and of course the records are not being inserted.
So is it even possible to call insert on a class level static List of records be inserted by a @future methods? I know an @future method can insert a List, but usually the list is created from within the @future method itself.
Thanks,
Jesse
Could you please share your code would be more helpful to understand the problem and tracing it.
Here is the framework of what i'm trying to do:
Okay so it looks like the class level variable isn't being maintained between methods. At the end of addProgramAppsToProgramsNewDevice the list contains records but when the @future method is called the list is empty.
Is there a way to maintain this class level List?
I am facing the same issue. Can you please share your solution ?
Same here, 2 years after...
Future method executes in a separate new context. It cant access any variables of class unless been passed.
In above scenario, you can have workaround by serializing your list devAppsToInsert and passing as String. In Future, deserialize it to List.
Check below link for code details:
https://www.mstsolutions.com/technical/passing-sobject-to-future-methods-in-salesforce/
Hope it helps!