0

I'm facing an issue with the below code. Can anyone help me to fix the issue.

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

Error line :

 If(brick.ZTS_EU_Market__c == marketlst){

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);
           }
         }
       }
   }
}

Thanks In advance, Raghu

1
  • It looks like you are comparing list value with String data value at place: brick.ZTS_EU_Market__c == marketlst,and so is the error Commented Jun 30, 2021 at 9:09

1 Answer 1

1

marketlst is an Array of strings - ie ['value1','value2','value3'];

You can't compare it to a string.

This is like saying if('value1' == ['value1','value2','value3'])

It might be better to just leave the marketValue as is (it's a string), and just do a contains on it.

Like so:

if (marketValue != null && marketValue.contains(brick.ZTS_EU_Market__c)){
  //rest of the loop

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .