+ Start a Discussion
dlCamelotdlCamelot 

Transform String Return to Row Return in Wrapper

Have code that successfully brings back a list of IDs for records (dnbFinalMatchList), however, I'd struggling to return this as a wrapper table instead.  My classes keep getting rejected.  See original working code below:
 
Public Class Foobar {

@AuraEnabled 
    public static List<String> getDnBMatches(String companyName){
        
        List<String> dnbFinalMatchList = new List<String>();  
        List<String> dnbCompleteMatches = new List<String>(); 
        List<String> dnbPartialMatches = new List<String>();
        List<String> nameFragments = new List<String>();
        List<DatacloudDandBcompany> dnbData2 = new List<DatacloudDandBcompany>();
        Integer emptyList = 0;
        Map<id,DatacloudDandBcompany> dnbData = new Map<id,DatacloudDandBcompany>();


        if (String.isnotBlank(companyName)){
            for (String fragment : companyName.split(' ')){
                     nameFragments.add(fragment);
                     system.debug('DC - Fragments - ' + nameFragments);
                } 


            if(nameFragments != null) {
                dnbData2 = [SELECT companyID,
                                                    Name,
                                                    DunsNumber,
                                                    City,
                                                    State,
                                                    Country,
                                                    Zip
                                      FROM DatacloudDandBCompany WHERE Name IN :  nameFragments LIMIT 50];
                system.debug(dnbData2);

                if(dnbData2 != null) {
                    for (DatacloudDandBCompany c: dnbData2 ){
                        if (companyName == c.name){
                            dnbCompleteMatches.add(c.companyid);
                        }
                        dnbPartialMatches.add(c.companyid); 
                        
                    }
                dnbFinalMatchList.addall(dnbCompleteMatches);
                dnbFinalMatchList.addall(dnbPartialMatches);
                system.debug(dnbFinalMatchList);
                return dnbFinalMatchList;
                }
                else {
                    return null;
                }

            }
            else {
                return null;
            }
        }
        else{
        return null;    
        } 
         
    }

}