1

Scenario:

I'm creating an unlocked package that is dependent on 3 other packages:

  • Package A - Managed base package (1st gen managed)
  • Package B - Managed extension package (extension of base, 1st gen managed)
  • Package C - Unmanaged extension package (extension of base, 1st gen unmanaged)

Package B adds some custom fields to a custom object that is in Package A.

In my unlocked package there's a report that references some of those fields, similar to this:

<groupingsDown>
    <dateGranularity>Day</dateGranularity>
    <field>PKGA__My_CustomObject__c$PKGB__My_CustomField__c</field>
    <sortOrder>Asc</sortOrder>
</groupingsDown>

My sfdx-project.json file references packages A,B,C as dependencies in the correct order:

{
    "packageDirectories": [
        {
            "path": "force-app",
            "default": true,
            "dependencies": [
                {
                    "package": "04t............"
                },
                {
                    "package": "04t............"
                },
                {
                    "package": "04t............"
                }
            ],
            "package": "My Unlocked Package",
            "versionName": "ver 0.1",
            "versionNumber": "0.1.0.NEXT"
        }
    ],
    "name": "My Unlocked Package",
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "51.0",
    "packageAliases": {
        "My Unlocked Package": "0Ho............"
    }
}

Error:

When I attempt to create a new version of the unlocked package using sfdx force:package:version:create I get the following error:

Invalid field name: PKGA__My_CustomObject__c$PKGB__My_CustomField__c

I haven't been able to figure out why I'm getting this error. Any ideas?

2 Answers 2

0

I recently discovered the root cause was that the report that was causing the error was using a custom report type that didn't include the fields from package B. Once I added those fields to the custom report type metadata, I was able to create the package version and release it.

0

I would Recommend you to Include (By Retrieving) the Custom Field PKGB__My_CustomField__c metadata into your Project CustomField section as well as on your package.xml manifest file.

Because the problem you are having while creating 2GP Package, is the custom field reference you have used on the Report, is not accessible by default while creating Package. So, if you add references for both the places mentioned above the problem will be resolved.

You must log in to answer this question.

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