I am having trouble in upserting a List. sObject may be Task or Account
public static void onTaskStatusChange(List<Task> newList, Map<Id, Task> oldMap) {
List<SObject> objectUpsertList = new List<SObject>();
for(Task newTask : newList) {
Task oldTask = null;
if(oldMap != null && oldMap.get(newTask.Id) != null) {
oldTask = oldMap.get(newTask.Id);
}
objectUpsertList = HelperClass.maintainTasks(newTask, oldTask);
if(objectUpsertList.isEmpty()) {
continue;
}
}
if(!objectUpsertList.isEmpty()) {
upsert objectUpsertList;
}
}
I am having error, while wriitting Test Method for this.
System.DmlException: Update failed. First exception on row 0 with id 00Tc000000CIr9iEAD; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Task_AfterUpdate: execution of AfterUpdate
caused by: System.TypeException: DML on generic List only allowed for insert, update or delete
Is there any work around for this?