1

I am getting an error when trying to create a version of my unlocked package after adding Apex code that references the Account.BillingCountryCode and Account.BillingStateCode fields. Everything is working properly in my scratch org with State and Country Picklists enabled and my DevHub org also has State and Country Picklists enabled.

When I try to create the unlocked package version, this is the error I receive:

AccountTriggerTest: Field does not exist: BillingCountryCode on Account
AccountTriggerTest: Field does not exist: BillingStateCode on Account

Does anyone have any ideas of how to remedy this other than using Sobject.get() and Database.query instead of SOQL to that the field names are strings rather than direct references?

2

In your project configuration, you can specify a definitionFile for your second-generation package:

... A reference to an external .json file used to specify the features and org settings required for the metadata of your package, such as the scratch org definition.

Just like with a regular scratch org definition file, the definition for your 2GP's build environment can include

  "features": [
    "StateAndCountryPicklist"
  ],

and similar declarations to configure the org to support your source.

| improve this answer | |
  • Bingo! That worked. Thank you for the quick response. – Jeff Freeman Oct 25 '19 at 21:53

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.