• Negro Dev
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Am running into an error in the Trailhead module for Packaging2.  I've downloaded the DreamHouse app and created the package without error.  But when I try to create a new version of the package, I get "An unexpected error occurred.  Please contact Salesforce Support and provide the following error code...."  It runs for about 2 minutes before it runs into this error.  I've started over from scratch.  I've remembered to put the pakcage id into the sfdx-project.json file.  I've double-checked that I'm connected to my DevHub.  I've double-checked that the force-app folder has the appropriate contents.  Any ideas where else to look?
We have a production organization with several dependencies on managed packages, both developed internally and from AppExchange.

We have several classes, triggers, formulas and validation rules using fields from internal managed packages. To test Salesforce DX I created a trial DevHub org with a few classes, custom objects, validations rules, etc. To test it in a scenario close to what we have in production, I installed our internal managed package in a scratch org and created classes with dependencies on it. As an example, we have a managed package DummyPackageX with an object DummyPackageX__User__c.

I can create scratch orgs, install the DummyPackageX depency on them and write my code without problems. When I finished my development and tried to package the code into a 2nd generation package to install it in a DevHub organization or in a Sandbox to test it I got an error:
 
> sfdx force:package2:version:create --directory force-app --wait 10
Request in progress. Sleeping 30 seconds. Will wait a total of 600 more seconds before timing out. Current Status='InProgress'
Request in progress. Sleeping 30 seconds. Will wait a total of 570 more seconds before timing out. Current Status='InProgress'
ERROR:  MyDummyClass: Invalid type: DummyPackageX__User__c,MyDummyClass: Invalid type: DummyPackageX__User__c,MyDummyClass: Variable does not exist: dummyuser.
It looks like when I try to pack my code using the command above, sfdx can't find the dependency for DummyPackageX. I tried to include the dependency into sfdx-project.json:
 
{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true,
      "id": "0Ho6A0000008OJHSA2",
      "versionName": "Apr 18 2018",
      "versionNumber": "1.0.0.0"
    }
  ],
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "42.0",
  "dependencies": ["04t0H0000015lgeQAA","04t30000001DUvrAAG","04t6A0000038AJeQAM"]
}

That doesn't seem to be working. Is it possible to have a 2nd generation package depending on a managed package not created with sfdx?

One of the limitations I see for 2nd generation packages in SFDX is:
Second-Generation Packages Cannot Depend on Packages Requiring an Installation Key

Does that mean I can't depend on a managed package from a Salesforce DX project?

Thank you.