I'm facing an issue of accessing objects, That is the first time I'm trying to use Global variables on APEX ;
I got a @future main method that calls two methods, In the first method I would like to fill values for a Map I will use on the second Method, without returning it (already returning another Map) ;
My idea was to use a variable declared as global on the Class level, but it seems impossible because of the future context... How could I do ? Returning the two maps, from the first method ?
I found that topic that match the context of my issue, no real answering however..
Class and global declared Map :
global with sharing class AP01_CrecheSiteWeb {
global Map<Id, List<Account>> mapIdContratToFinalListCreches {get; set;}
...
The @futur method :
@future
public static void updateCrecheSiteWeb(List<Id> listCZDTIds) {
// Call first method - I want it to set another map in order to access it in the 2nd method !
Map<Id, List<Account>> mapIdContratToListAssociatedCreches = getMapContractToCreches(listCZDTIds);
try {
// Call second method, that should use the map set in the 1st method, and of course the map returned by the 1st method
getMapContractToCrechesSiteWeb(mapIdContratToListAssociatedCreches);
} catch (Exception ex){
System.debug('--AP01_CrecheSiteWeb EXCEPTION --' + ex.getMessage());
}
}
First method (parts of) :
public Map<Id, List<Account>> getMapContractToCreches(List<Id> listCZDTIds) {
[...]
// I want to do something like this :
Map<Id, List<Account>> getGlobalMap = this.mapIdContratToFinalListCreches;
[...]
return anotherMap;
}
And the 2nd method would do the same, get the global Map, use it, clear it.