I got some advice a couple days ago to improve my batch updater class. I have been working on it but am getting a compile error. I get the error:
DML requires SObject or SOBject list type: Map Line 20
The line is where I update the map pipelines. Why do I get this if I have Map pipelines = new Map(); in the method?
Code example:
global void execute(Database.BatchableContext BC, List<Revenue_Pipeline_Schedule__c> scope) {
Map<Id, Revenue_Pipeline__c> pipelines = new Map<Id, Revenue_Pipeline__c>();
for (Revenue_Pipeline_Schedule__c schedule : scope)
{
Id pipelineId = schedule.Revenue_Pipeline__c;
pipelines.put(pipelineId, new Revenue_Pipeline__c(Id=pipelineId));
}
// now all keys are initialized
for (Revenue_Pipeline_Schedule__c schedule : scope)
{
SObjectField field = RevenuePipelineScheduleUpdaterHelper.dateToField.get(schedule.Date__c);
if (field != null)
{
pipelines.get(schedule.Revenue_Pipeline__c).put(field, schedule.Amount__c);
}
}
update pipelines;
}