SFDX: Salesforce Package Versions depend on Scratch Org Definition

While implementing a Salesforce Package Version for my private Salesforce package, I encountered an interesting fact: The creation of the Salesforce Package Version is only possible if the right corresponding Scratch Org Definition file is provided.

Scenario

I noticed that the issue when I wanted to create a custom field that is dependent on the “Person Account” feature.

1. I first modified my scrtach org permission file to enable personaccounts.

1.png

2. I created a new scratch org.

2.png

3. After creating and adding a new field that dependet on Person accounts, I tried to create a new package version.

5.png

4. My new package version was rejected with the following error message:

ERROR:  Account.Person_Account__c: Field IsPersonAccount does not exist. Check spelling.

6.png

The error message does not indicate what is actually the issue. The system just suggest that the IsPersonAccount field is not existing.

Solution

The solution is comparable obvious. The Scratch Org Definition File is missing. As indicated in the documentation the file is not mandatory. However, it is required in case the package is dependent on specific Salesforce Org Features:

-f | –definitionfile DEFINITIONFILE Optional

The path to a definition file similar to scratch org definition file that contains the list of features and org preferences that the metadata of the package version depends on.

Type: filepath

By including the scratch org definition file the package version could be created easily without any further issues.

7.png

Learning: The scratch org definition file is not mandatory, but required in case the package is refering to any specific Salesforce feature.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s