-3

I'm getting an error on he below code please correct me. Not sure what's missing.

ERROR : Error: Compile Error: Comparison arguments must be compatible types: String, List at line 30 column 20

Error showing at this line :

If(brick.ZTS_EU_Market__c == marketlst){

The more complete code is:

     public class ZIP_TerritoryBrickCodePopulation{   
         public void territoryBrickCodePopulation(List<Account> accList){
        
        String marketValue = system.label.BrickToTerritory_Market;
        List<String> marketlst = marketValue.split(',');
        Set<String> zipcodes=new Set<String>(); 
        Set<String> marketSet = new Set<String>();
        Set<String> zipMarketKey =new Set<String>();
          
        List<ZTS_GL_BrickToTerr__c> lstBrick = [select Id,Name,ZTS_EU_Market__c,ZTS_EU_BrickName__c,ZTS_EU_Territory__c from ZTS_GL_BrickToTerr__c];
         
        for(Account acc:accList){        
            
            for(ZTS_GL_BrickToTerr__c brick : lstBrick){
            
                If(brick.ZTS_EU_Market__c == marketlst){
                              
                    if(!String.isBlank(acc.ZTS_EU_Zip_Postal_Code__c) && acc.ZTS_EU_Market__c != ZTS_EU_GlobalConstants.MARKET_VAL && acc.ZTS_EU_Market__c != ZTS_EU_GlobalConstants.UK_MARKET_VAL){
                        zipcodes.add(acc.ZTS_EU_Zip_Postal_Code__c);
                    }else if(acc.ZTS_EU_Market__c == ZTS_EU_GlobalConstants.MARKET_VAL){
                        zipcodes.add(acc.ZTS_EU_State_County_Value__c);
                    }else if(!String.isBlank(acc.ZTS_EU_Zip_Postal_Code__c) && acc.ZTS_EU_Market__c == ZTS_EU_GlobalConstants.UK_MARKET_VAL){
                        zipcodes.add(acc.ZTS_EU_UK_PC4_from_Postalcode__c);
                    }
                    marketSet.add(acc.ZTS_EU_Market__c);
           }
         }
       }
   }
}
0

1 Answer 1

0

Simply using an IDE would help you find such issues. Salesforce even has a free plugin for VSCode, plus all the instructions you need to install and get started with it.

The problem is that you are using a comparison between a string and a list:

If(brick.ZTS_EU_Market__c == marketlst){

should probably be:

If(marketlst.contains(brick.ZTS_EU_Market__c)){

This will then return true if the marketlst contains the specified EU Market value. Note that this is case and whitespace sensitive; this will be an exact match only.

4
  • Phil I have modified the code but getting this error. Pls help me I have updated error details.Thanks
    – Raghu
    Jun 30, 2021 at 8:27
  • Follow the path of setting up an IDE. Your whole development experience will be much smoother.
    – Phil W
    Jun 30, 2021 at 8:29
  • Sure Phil. For now can you help me to resolve the issue. till I'm getting another error and I have updated in post please check and help me accordingly. Thanks
    – Raghu
    Jun 30, 2021 at 8:33
  • By editing the question in the way you did, you invalidated the analysis part of my answer. Since I had provided an answer you should have simply raised a new question instead of updating this one; this Q&A posting is now confusing.
    – Phil W
    Jun 30, 2021 at 8:59

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