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?

1 Answer 1

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.

1
  • Bingo! That worked. Thank you for the quick response. Oct 25, 2019 at 21:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .