I have a simple batch with global variable as :
global with sharing class sampleBatchApex implements Database.Batchable<sObject>{
global List<Case> myList;
global Database.QueryLocator start(Database.BatchableContext BC){
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
//some stuff;
}
global void finish(Database.BatchableContext BC){
myList = SELECT ID ... FROM ...
}
}
And an other where I try to get myList
public class BatchApexProgressIndicatorController {
public static sampleBatchApex myBatchObject = new sampleBatchApex();
the batch is executed in an other method, and I'm monitoring the job. Once it's finished, I'm calling the following method to get myList
@AuraEnabled
public static List<Case> getCases(){
return myBatchObject.myList;
}
}
It keeps me getting empty list.
However if I System.debug the list in the finish method of the batch, i can see that the list is not empty.
Could you please hint me on how can I get this list from the other class ?
Thank you