0

I am fairly new to Salesforce, and currently trying to explore Connected App in 2GP. I have done some reading and came across some posts that is similar to my situation here. Package Connected App Salesforce Guide and also answer from Mohith here. However, I am still confused and stucked. Just a bit of background on what I have done so far:

  1. Enabled Dev Hub and Second-Generation Managed Packaging
  2. Signed up for Developer Edition Org, registered a namespace and linked to Dev Hub Org
  3. Created a scratch org to develop my Connected app
  4. Pulled source from scratch org into local project (I'm using VS Code), convert source to mdapi and deploy it to Developer Edition Org that has my namespace
  5. Created 1GP Managed package in Developer Edition Org.
  6. Created package version and promoted it to Released state. (At this point I have tried installing my package into other scratch orgs, and things seem to be working fine)

Here comes my questions. According to the guidelines provided, my next step should be creating a source .xml file in my 2GP directory, and create package and package versions.

  1. Where exactly is 2GP Directory/ source directory ? Where should I create the source .xml file?
  2. In the final step, which is to create 2GP package and package versions, which is my target org here? Is it Developer Edition Org?

Appreciate if anyone can provide a more detailed guideline, or any other pages/ materials that I can refer to. Thanks in advance.

1

Where exactly is 2GP Directory/ source directory ? Where should I create the source .xml file?

Assuming a default package structure, it'd be in force-app/main/default/connectedApps/. The file name should match the name of the Connected App. You can read more about the XML file structure in the documentation.

In the final step, which is to create 2GP package and package versions, which is my target org here? Is it Developer Edition Org?

Your 2GP will be created in your Dev Hub org, whatever that means. In most typical organizations, this is your Production Org. In the 2GP model, your packages are sourced from your local files, then uploaded and stored in the Dev Hub org for installation and distribution.

4
  • Hey @sfdcfox, thanks for the explanation. Not sure if I'm understanding this correctly, so I have pulled my source from scratch org into local project, hence under force-app/main/default/connectedApps/ I have got my XML file for the connected app, am I right to just edit that existing file to include <developername> and <version> in the step of creating a source .xml file in my 2GP directory ? – Yean Chiat Jan 3 at 8:03
  • Also, when creating 2GP package and package versions, are we supposed to use sfdx force:package2:create? I have read this somewhere when researching online, but it seems like my VS Code is telling me this command does not exists. I have tried creating the package by just using sfdx force:package:create, just I'm not sure if the package created is it really a 2GP. – Yean Chiat Jan 3 at 8:08
  • @YeanChiat (a) Yes, it's automatically in the right place, you can edit as needed. (b) force:package2:create was removed at some point, it's now force:package:create -t Managed (the -t Managed is a parameter that specifies the type of package to create). This simplifies the command a bit, as you can now create package versions for both Unlocked and Managed packages with the same command (force:package:version:create). – sfdcfox Jan 3 at 13:58
  • Thanks a lot! That really clear things up for me, appreciate your help @sfdcfox – Yean Chiat Jan 4 at 2:16

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.