I am using an iterator to use an aggregate query on a custom object looking for unique years. on the very last iteration, I want to change a value, so I am hoping to use hasNext, but it looks like i only have the scope, which is a list, and the batchable context. I dont quite see how to call the iterator while in the execute portion of the batch file
private TokenResponse tokenResponse;
global Iterable<AggregateResult> start(Database.BatchableContext bc) {
tokenResponse = API_Interface.getToken();
system.debug(tokenResponse);
return new RST_TitleYearIterable(
'SELECT Calendar_Year(Wide_Release_Date__c) openYear, count(Id) num FROM Title__c GROUP BY Calendar_Year(Wide_Release_Date__c)'
);
}
global void execute(Database.BatchableContext bc, List<SObject> scope){
system.debug('scope : ' + scope);
for(sObject sObj : scope) { // there should be only one
AggregateResult ar = (AggregateResult)sObj;
System.debug('>>>> COUNT : ' + ar.get('num') + ' during >>>> YEAR : ' + ar.get('openYear'));
// check if iterator has next??
...
Could I store the iterable as a private variable and access it and its current index?