function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sriram anilsriram anil 

Error: Compile Error: Incompatible key type Decimal for Map<Integer,String>

any one pls explain and solve this error:


Trigger basicTrigger on account(before insert,before update){
    
    if(trigger.isbefore && Trigger.isInsert){
        
        List<Country_barcodes__c> mcs = Country_barcodes__c.getall().values();

        Map<integer,String> countryWithPhone = New Map<integer,String>();
         
        for(integer i=0;i<mcs.size();i++){
            countryWithPhone.put(mcs[i].country_phone_code__c,mcs[i].Name);
        }
        
         
        for(integer i=0;i<trigger.new.size();i++){
            if(countryWithPhone.ContainsKey(Trigger.new[i].BillingCountry)){
                trigger.new[i].Phone = countryWithPhone.get(Trigger.new[i].BillingCountry);
            }else{
                trigger.new[i].BillingCountry.addError('COUNTRY CODE DOES NOT EXISTS');
            }
        }
    }
  
}
ManojjenaManojjena
HI Sriram,

Can you please explain your requirment ,As you are creating a map of integer and String ,Also in second loop you want to get with billing country which may not be an integer .

Explain your requirment I will help you write code in an optimised manner .
sriram anilsriram anil
I am creating custom setting Object 1st
in this object Country_barcodes__c two field creating
1is country_phone_code__c---->country phone codes
2nd country barcode---->like Ex:Name:INDIA---->barcode-Ind

i am insert  new record into account
BillingCountry is i am enter india automatically phone field also show phonecode like 91