I have custom setting"CountryCodeMapping__c" to map the country values which has 2 fields,

  • Salesforce_CoutryValue__c
  • ExtSystem_CountryValue__c

This custom setting has used in Apex class where we are mapping the country field with external system's field.

  • Salesforce_CoutryValue__c = United States of America
  • ExtSystem_CountryValue__c = USA

If the country value is USA in external system, it is updating as United States of America as per in the settings in salesforce.

All the country values are getting mapped properly except the country value Cote D'ivoee, its throwing the below error message.
"Primary Country Code: bad vlaue for restricted picklist field: Cote D'ivoee "

below is the actual country value in custom setting.

  • Salesforce_CoutryValue__c = Cote D'ivoee

  • ExtSystem_CountryValue__c = Cote D'ivoee

When i check the response i can see the value is coming properly from the external system as "Cote D'ivoee" Dont know where it is getting encrypted as "Cote D'ivoee"
To fix this issue i tried by giving the encrypted values directly in the custom setting as below, but doesnt work.

  • Salesforce_CoutryValue__c = Cote D'ivoee

  • ExtSystem_CountryValue__c = Cote D'ivoee

Kindly provide some solution to get out of this issue. It would be very helpful for me, Thanks in Advance!


It seems that characters are encoded to be HTML friendly when you pull them from external systems. You basically want to unescape these characters, so I think the following URL might be of use to you:


Have a look at using the unescapeHtml4 method on the Strings that come from your external system before comparing them with your Custom Setting!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.