2

I am trying to switch to DX but noticed that the CountryCode and StateCode are no longer being recognized by Salesforce in DX environment. Trying to reference those fields gives me an invalid field error.

Has anybody else experienced this? Is this something that SF is planning to address?

  • 4
    Did you enable State&Country Picklists? This feature must be active for these fields to show. Only posting as comment since it's not clear if that's the issue. – Adrian Larson Jan 22 '18 at 19:01
  • 1
    Just as a note to Adrian's comment: with Salesforce DX when you create a scratch org you need to specify which features are enabled when it is created. This includes almost every setting you can enable on the setup (multi-currency, as another example). – Renato Oliveira Jan 22 '18 at 19:05
  • Thanks to both of you. Let me dig a little deeper into it and I will report back! – Arthlete Jan 22 '18 at 19:07
  • 1
    Here's a link to the Screatch Org Definition File: developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/… I couldn't see if there is an option to enable State&Country Picklists there, but I think you can enable it after the org is created. – Renato Oliveira Jan 22 '18 at 19:21
  • @RenatoOliveira - I couldn't find anything in the developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/… to enable this from within the configuration. Do you have an idea of there could be some additional documentation that perhaps I am missing? – Arthlete Jan 22 '18 at 20:09
4

Make sure you enable State and Country Picklists, as this feature must be enabled for StateCode and CountryCode fields to show up.

| improve this answer | |
  • Just tested, that's it! Thanks I completely forgot about doing this! – Arthlete Jan 22 '18 at 19:22

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.