You need to sign in to do that
Don't have an account?

Method does not exist or incorrect signature: [Set<String>].containsIgnoreCase(String)
Hi Friends,
I am getting following error in my trigger while ignoring the casesensitive. can any one help me what mistake did i made in the following trigger.
My requirement is to autopopulate Region__c custom field in Account when i give Account billing country. For this requirement I have created custom setting called country_Names__c with country_Region as custom field. without containsIgnoreCase it is working fine but when i try to enter Billingcountry in lowercase the Region__c field is not autopopulated for this i want to ignore the caseinsensitive.
error:"Method does not exist or incorrect signature: [Set<String>].containsIgnoreCase(String)"
trigger:
trigger ReportsAccount on Account (before insert, before update) {
Map<string,Country_Names__c> countries=Country_Names__c.getAll();//get all the countries
set<string> countrynames= new set<string>();
countrynames.addAll(countries.keySet()); // add map country keys to set
if(trigger.isInsert){
for(Account a:trigger.new){
if(countrynames.containsIgnoreCase(a.BillingCountry)){ //error line without ignore case it is working fine
a.Region__c=countries.get(a.BillingCountry).Country_Region__c;
}
} // loop ends
}
if(trigger.isUpdate){
for(Account updateacc: trigger.new){
if(countrynames.contains(updateacc.BillingCountry)){
updateacc.Region__c=countries.get(updateacc.BillingCountry).Country_Region__c;
}
}// loop ends
}
}
I am getting following error in my trigger while ignoring the casesensitive. can any one help me what mistake did i made in the following trigger.
My requirement is to autopopulate Region__c custom field in Account when i give Account billing country. For this requirement I have created custom setting called country_Names__c with country_Region as custom field. without containsIgnoreCase it is working fine but when i try to enter Billingcountry in lowercase the Region__c field is not autopopulated for this i want to ignore the caseinsensitive.
error:"Method does not exist or incorrect signature: [Set<String>].containsIgnoreCase(String)"
trigger:
trigger ReportsAccount on Account (before insert, before update) {
Map<string,Country_Names__c> countries=Country_Names__c.getAll();//get all the countries
set<string> countrynames= new set<string>();
countrynames.addAll(countries.keySet()); // add map country keys to set
if(trigger.isInsert){
for(Account a:trigger.new){
if(countrynames.containsIgnoreCase(a.BillingCountry)){ //error line without ignore case it is working fine
a.Region__c=countries.get(a.BillingCountry).Country_Region__c;
}
} // loop ends
}
if(trigger.isUpdate){
for(Account updateacc: trigger.new){
if(countrynames.contains(updateacc.BillingCountry)){
updateacc.Region__c=countries.get(updateacc.BillingCountry).Country_Region__c;
}
}// loop ends
}
}
Issue is coming because you are using String method with Set. you can try any of below solution
Please update your code like below . Same code will work with insert and update case.
Let us know if this will help you
All Answers
try this code let me infotm if it helps you
thanks :)
Issue is coming because you are using String method with Set. you can try any of below solution
Please update your code like below . Same code will work with insert and update case.
Let us know if this will help you