You need to sign in to do that
Don't have an account?
sriram 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');
}
}
}
}
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');
}
}
}
}
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 .
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