I have the following method:
public static void updateCaseLastEmailStatus(List<EmailMessage> emUpdateCase) {
Id caserecordType = Schema.SObjectType.Case.getRecordTypeInfosByDeveloperName().get('CaseRecordPage').getRecordTypeId();
List<Case> caseUpdate = new List<Case>();
List<Id> listIds = new List<Id>();
for (EmailMessage eMsg : emUpdateCase) {
listIds.add(eMsg.RelatedToId);
}
caseUpdate = new List<Case>([SELECT Last_Email_Status__c,
(SELECT Status FROM EmailMessages
ORDER BY CreatedDate DESC LIMIT 1 )
From Case WHERE RecordTypeId = :caserecordType AND ID IN: listIds]);
for(Id caseId : caseUpdate) {
Case myCase = caseUpdate.get(caseId);
myCase.Last_Email_Status__c = EMAIL_STATUSES.get(myCase.EmailMessages[0].Status);
}
update caseUpdate.values();
}
When I try to save the file, it gives me the following three error:
Method does not exist or incorrect signature: void get(Id) from the type List
Invalid loop variable type expected Case was Id
Method does not exist or incorrect signature: void values() from the type List
casesById
(i.e. thingsByKey)