0

Invalid type: EcPerformanceRecordList

I want to create a Map of userid and list of sObject records, then loop through this map so that I can count how many apps have been submitted per user.

This is an example of the EcPerformanceRecordList: e.g

UserID  Total  EC(Yes)     Date
user1   12      4          06/12/2019
user1   13      13         06/13/2019
user2   35      24         06/18/2019
user3   23      31         07/02/2019    
user1   17       2          07/10/2019
user3   12       3          07/10/2019

Map<String, List<EcPerformanceRecordList>> ecusermap = new  Map<String, 
List<EcPerformanceRecordList>> ecusermap();



ecusermap.put(user1, <{user1 12 4 06/12/2019}, {user1 13 13 06/13/2019},{user1 17 2 07/10/2019} )

ecusermap.put(user2, <{ user2 35 24 06/18/2019}, {user1 13 13 06/13/2019},{user1 17 2 07/10/2019} ) and so on.

then for each user, i want to loop through the list and calculate the totals.

Here's snippet of my code for reference.

public with sharing class MyController {

    public list<MyWrapper> wrapper {get;set;}
    public integer appTotal {get;set;} 
    public integer mtdappTotal {get;set;} 
    public integer previousmonthappTotal {get;set;} 
    public integer idlplusmtdTotal {get;set;}
    public integer idlpluspreviousmonthTotal {get;set;}
    public integer caTotal {get;set;}
    public integer ecmtdTotal {get;set;}
    public integer ecpreviousmonthTotal {get;set;}
    public integer ecEligibleYesMTDTotal {get;set;}
    public integer ecEligibleYesPreviosMonthTotal {get;set;}
    public Map<String,list<EcPerformanceRecordList>> ecusermap {get;set;}


    @AuraEnabled(cacheable=true)
    public void getdeserialize() {

        try{
            string jsonresponse = 'SOME STRING'


            wrapper = (list<MyWrapper>) JSON.deserialize(jsonresponse, list<MyWrapper>.class);


            // call the method that aggregates the MonthToDate app count, and PreviousMonth app count per user 
            getTotalECBookedByUser(wrapper);



        } catch (Exception e){
            system.debug('Error---->' +  e.getLineNumber() + e.getMessage());

        }
    }



// This method calclates the total EC Booked current month and previous month by each user 
public integer getTotalECBookedByUser(list<MyWrapper> wrapper) {

    // create a map of submitUserID and ECSubmittedRecordList 
    Map<String,list<EcPerformanceRecordList>> ecusermap = new Map<String,list<EcPerformanceRecordList>>();  
    for(MyWrapper jw: wrapper){

        jw.ecpreviousmonthTotal=0;
        jw.ecmtdTotal = 0;   

        for (MyWrapper.EcPerformanceRecordList ec : jw.ecPerformanceRecordList) {

            if(ecperuserMap.containsKey(ec.submitUserID)){

                 ecperuserMap.get(ec.submitUserID).add(ec);

            }else {

                ecperuserMap.put(ec.submitUserID,ec);
            }

        }
    }

    //TODO: 
    // for each key, loop through the values in ecperuserMap and count the total apps submitted by each user this month and previous month 



    return ecpreviousmonthTotal;
    return ecmtdTotal;

}



}




------------------------Wrapper Class ------------------


public class MyWrapper {
@AuraEnabled    
public List<CaPerformanceRecordList> caPerformanceRecordList{get;set;}
public List<EcPerformanceRecordList> ecPerformanceRecordList{get;set;}
public Map<String,List<EcPerformanceRecordList>> ecPerUser {get;set;}
public integer appTotal{get;set;}
public integer mtdappTotal {get;set;} 
public integer previousmonthappTotal {get;set;} 
public integer idlplusmtdTotal {get;set;}
public integer idlpluspreviousmonthTotal {get;set;}
public integer caTotal {get;set;}
public integer ecmtdTotal {get;set;}
public integer ecpreviousmonthTotal {get;set;}
public integer ecEligibleYesMTDTotal {get;set;}
public integer ecEligibleYesPreviosMonthTotal {get;set;}





public class EcPerformanceRecordList {
    public String DealerID{get;set;}
    public String submitUserID{get;set;}
    public String bookedDate{get;set;}
    public String ecEligible{get;set;}
    public Integer caBookedCount{get;set;}
    public Integer ecBookedCount{get;set;}


}


public class CaPerformanceRecordList {
    public String DealerID{get;set;}
    public String dealerName{get;set;}
    public String reportingPeriod{get;set;}
    public String financeSourceIntegrationTypeCode{get;set;}
    public String idlPlus{get;set;}
    public String creditApplicationSourceCode{get;set;}
    public Integer submissionCount{get;set;}
}


}
3

EcPerformanceRecordList is an inner class of MyWrapper. Outside the scope of MyWrapper, including inside the class MyController, you must refer to it with its fully-qualified name MyWrapper.EcPerformanceRecordList:

public Map<String,list<MyWrapper.EcPerformanceRecordList>> ecusermap {get;set;}

and so forth.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.