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
ynwaynwa 

Save error: Method does not exist or incorrect signature

Hi All,

I'm a new coder and this is my first trigger. I am trying to match a field on the custom object with accounts on insert and update. I get save error on "Method does not exist or incorrect signature: map_CountryPostcode_to_SalesRepSC.containsKey(String)" I have underlined the line where the error occurs.

 

What I am trying to do is match the CountryPostcode field in custom object Sales_territory with concatenated account billing country and account billing postcode.

 

Thanks for your help!

 

 

trigger Assign_Sales_Rep on Account (before insert, before update) {

 // Grab Terriory information based on CountryPostcode
 	map<String, String> map_CountryPostcode_to_SalesRepCS = new map<String, String>();
 	map<String, String> map_CountryPostcode_to_SalesRepM = new map<String, String>();
 	
 	string AccCountryPostcode = '';	

	for (Sale_Territory__c [] li_Sale_Territory: [ select CountryPostcode__c,
											Sales_Rep_CS__c,
											Sales_Rep_M__c
										from Sale_Territory__c
										]) 
	{
		for(Sale_Territory__c sSale_Territory : li_Sale_Territory)
		{
			map_CountryPostcode_to_SalesRepCS.put(sSale_Territory.CountryPostcode__c, sSale_Territory.Sales_Rep_CS__c);
			map_CountryPostcode_to_SalesRepM.put(sSale_Territory.CountryPostcode__c, sSale_Territory.Sales_Rep_M__c);
			
		}								
	}
	
	
    for (Account sAccount : trigger.new)
    {
    	AccCountryPostcode = 'sAccount.BillingCountry'+'sAccount.BillingPostalCode';
    	if (sAccount.BillingPostalCode == null || sAccount.BillingPostalCode == '' || sAccount.BillingPostalCode == ' ' || sAccount.BillingCountry = Null || sAccount.BillingCountry = '' ||sAccount.BillingCountry = ' ')
           {
              //sAccount.ShippingPostalCode.AddError('Billing Postal Code OR Billing Country can not be null');
           }
           else 
           {
           		if (map_CountryPostcode_to_SalesRepSC.containsKey(AccCountryPostcode))
           		{
           			sAccount.Sales_Rep_CS__c = map_CountryPostcode_to_SalesRepCS.get(AccCountryPostcode);       			
           		}
           		else
           		{
           			sAccount.Sales_Rep_CS__c ='';
           		}
           		if (map_CountryPostcode_to_SalesRepM.containsKey(AccCountryPostcode))
           		{
           			sAccount.Sales_Rep_M__c = map_CountryPostcode_to_SalesRepSC.get(AccCountryPostcode);       			
           		}
           		else
           		{
           			sAccount.Sales_Rep_M__c ='';
           		}
           }           
    }


}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Leon MorockiLeon Morocki

There is a typo: SC instead of CS

All Answers

Leon MorockiLeon Morocki

There is a typo: SC instead of CS

This was selected as the best answer
ynwaynwa

Thanks Leon!!

 

I was so busy trying to get the coding correct I missed the typo. Thanks again!