I have a Map inside a Map where I want to put values of type String (TechDayMonthYear_2__c) and Decimal (AttendanceRate_2__c). But I get 2 errors "Invalid type: tp.AttendanceRate_2__c" and "Invalid type: tp.TechDayMonthYear_2__c and don't understand why since it's the right types for both fields. Here is my code :
Map<Integer, Map<String, Decimal>> workedDaysByMonth = new Map<Integer, Map<String, Decimal>>();
List<Taux_Presence__c> allAttendanceRates = [SELECT Id, User__c, AttendanceRate_2__c, AttendanceRate_3__c,
AttendanceRate_4__c, AttendanceRate_5__c, AttendanceRate_6__c,
TechDayMonthYear_2__c, Tech_Mois_Creation_3__c, Tech_Mois_Creation_4__c,
Tech_Mois_Creation_5__c, Tech_Mois_Creation_6__c, Tech_External_Id__c
FROM Taux_Presence__c
WHERE User__c IN :this.reportsByUserId.keySet()];
for(AttendanceRate__c tp : allAttendanceRates){
for(Integer dayMonthYear : daysNumbersInQuarter.keySet()){
workedDaysByMonth.put(dayMonthYear, new Map<tp.TechDayMonthYear_2__c, tp.AttendanceRate_2__c>());
}
}
allAttendanceRates
's type does not match yourfor
loop.