Skip to main content
31 votes
Accepted

Extension packages & Licence Management in 2GP

Thanks for the question! I've created an answer in three parts, each one meant to address a specific question you've asked. PART ONE: How to Create Second-Generation Extension Packages PART TWO: How ...
Vivek M. Chawla's user avatar
19 votes

Modularize (existing) LWC for reuse and flexible distribution

This is a complex topic and I’m going to do my best to give some quick pointers but we could fill an entire white paper on this theme and I’m sure that are some things that I might overlook. Inter-...
POZ's user avatar
  • 4,419
16 votes

Second gen package error about a component being a scratch org ancestor? What does this mean?

I just ran into the same issue. Trying to install my namespaced package into a scratch org with the same namespace. You need to create a scratch org without a namespace using the --nonamespace flag ...
RockPile's user avatar
  • 303
16 votes
Accepted

Best practices for breaking 1 GP monoliths into 2GP modules

This is a great topic. Many Salesforce Partners are exploring ways they can leverage 2GP today, even as they wait for 1GP=>2GP migration which is currently available only as a developer preview (...
Vivek M. Chawla's user avatar
13 votes
Accepted

Do 2GP Managed Packages send email notifications on unhandled Apex errors?

Yes, unhandled exception emails do work with 2GP. I confirmed this by creating a managed 2GP with a Visualforce Controller that tries to divide by zero if a certain custom metadata record is set to ...
Vivek M. Chawla's user avatar
12 votes
Accepted

How do I package an upgradable Experience Builder Site?

This seems so simple on the face of it, but ends up quite difficult to achieve. I did manage, and on the way learned quite a bit. The main learning points: You have to have just the right metadata ...
Phil W's user avatar
  • 37k
11 votes
Accepted

I want to package (unlocked 2GP) a Digital Experience; what metadata do I need?

It's quite a long journey to work out what metadata you want to package in 2GP since you have to manually add all those dependency metadata items for yourself. Since Salesforce doesn't yet provide ...
Phil W's user avatar
  • 37k
9 votes
Accepted

Converting First Generation Managed Package to Second Generation (2GP) Packages

November 2020 Answer Converting from 1GP to 2GP is in Developer Preview in the Winter '21 (Oct 2020) release. You can join the Partner Community group which has all of the instructions for getting ...
daveespo's user avatar
  • 2,683
7 votes

fflib as Second Generation Managed Package (2GP)

I'll start this answer by recognizing that questions which solicit opinions, rather than objective answers, are frowned upon on StackExchange. Having said that, the question was framed beautifully and ...
Vivek M. Chawla's user avatar
7 votes

Packaging Connected App in 2gp package - CLI says package is deleted?

You don't actually need to package the Connected App, especially when all/many of your clients use the same connected app with the same secret/ID and same mobile app (for example). The important thing ...
Phil W's user avatar
  • 37k
6 votes

'ParentId' field missing when deploying ExperienceBundle - 2GP

If you have enabled the ExperienceBundle Metadata API in the Dev Hub and you're still getting this error, remove the <networkMemberGroups> from the Network file of your Community. Due to a bug ...
TheLeonKing's user avatar
6 votes
Accepted

2GP Extension Package With Dependencies on External Packages

The answer is yes, absolutely. Unfortunately the Scratch Org creation mechanism isn't yet smart enough to deal with this for you and Salesforce suggested writing scripting to deal with installing the ...
Phil W's user avatar
  • 37k
6 votes

Can a 2GP package include a post install page?

I raised this on the Partner Forums too. I got the following from two of the guys at Salesforce. Firstly Dileep Burki: The postInstallURL supports the specification of a URL to which the installer is ...
Phil W's user avatar
  • 37k
6 votes
Accepted

How update Managed Packages (2GP) if one of the Apex classes is scheduled Apex

According to this question on the Developerforce platform, a user discovered that you can install an update even while a Schedueable class is scheduled. I can't find any documentation on the matter, ...
sfdcfox's user avatar
  • 497k
6 votes
Accepted

Enabling Unlocked Packages and 2GP on a HUB

What will happen to 1GP packages if we turn on "Enable Unlocked Packages and Second-Generation Managed Packages"? Nothing. But there's an assumption here that cannot be correct: my company ...
David Reed's user avatar
  • 93.2k
5 votes
Accepted

ERROR running force:org:create: We don’t recognize this namespace: x. Did you register it in your Dev Hub org?

The documentation specifically says: Sign up for a new Developer Edition org I.e. you are right; you must have an org on which the namespace is defined and the (recommended) way of doing that is to ...
Phil W's user avatar
  • 37k
5 votes
Accepted

Change version number scheme in sfdx-project.json

This isn't currently allowed because it's not necessarily a good idea. The way versions work in Salesforce is that each version installed is tracked by the platform. Metadata that depends on a version ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

2GP Create Package Version Fails when running tests

Using System.RunAs in your test methods is the recommended way to solve these in Test class execution. This ensures that the Test Execution context does not depend on the current user in the org. This ...
Mohith Shrivastava's user avatar
5 votes
Accepted

Include two different package Directories during unlocked package creation

No, you're not missing anything. Each package may only be one directory. From your question, it appears you want two packages, with the force-app package depending on the common package. { "...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

How do we handle additions to page layouts with SalesforceDX / 2GP?

The only reasonable way to handle a page layout setup, given the dependencies required, is to make the page layout a package that actually depends on all of the other packages. This has the ...
sfdcfox's user avatar
  • 497k
5 votes
Accepted

Apex compile failure on package installation

As at Spring '21, 2GP managed packages do not support component deletion, as covered in the 1GP vs 2GP gap documentation. A rename is equivalent to delete (old name) and add (new name). Salesforce ...
Phil W's user avatar
  • 37k
5 votes

Extension packages & Licence Management in 2GP

2GP managed packages only appear in the LMA after security review has been passed (as you have pondered). (Note that, as an aside, without the security review being passed it is actually impossible to ...
Phil W's user avatar
  • 37k
5 votes
Accepted

Push upgrade app for second generation packages?

There is a Salesforce Labs application called Package Visualizer that offers, as part of its functionality, scheduling push upgrades for 2GP managed packages. The user guide for the application ...
David Reed's user avatar
  • 93.2k
5 votes

fflib as Second Generation Managed Package (2GP)

G'day folks. Apologies for being a bit late to this discussion. @lightxx -- There are pros and cons about separating the fflib classes out to a new package. All things being equal, it makes sense to ...
ImJohnMDaniel's user avatar
5 votes
Accepted

Modularize (existing) LWC for reuse and flexible distribution

Note: With permission from the original author, Salesforce's own Aditya Naag, I am reposting here some highlights of his ApexHours session. The slides can be downloaded here. We rarely write code ...
Robert Sösemann's user avatar
5 votes

What are best practices for global class / method in 2GP in AppExchange?

Note: The following is from 5+ years experience developing 1GPs and 2+ years with 2GPs as an ISV... it can, however, be viewed as opinionated. According to the documentation on metadata deletion for ...
Phil W's user avatar
  • 37k
5 votes
Accepted

2GP Unlocked package show CustomTab on install?

You can't. Typically, vendors will create their own custom app and include it in the package. This way, users can switch to your app and use the tabs in the way that you intended.
sfdcfox's user avatar
  • 497k
4 votes

'ParentId' field missing when deploying ExperienceBundle - 2GP

After a painful 2 week trial and error dance with Salesforce Support (Case: #26307915), we learned that we have to do something very unintuitive. It's a setting in the Dev Hub org which needs to be ...
Anmol Kumar's user avatar
  • 3,651
4 votes
Accepted

How to use second generation packaging (2GP) for a community?

The packaging for a second-generation package takes place in a "behind-the-scenes" scratch org that Salesforce calls a build org. That build org needs to be configured with the right ...
David Reed's user avatar
  • 93.2k
4 votes

2GP Extension Package With Dependencies on External Packages

It's definitely possible to create 2GP dependent packages where the Parent Package is Health Cloud, FLS, or any other Managed/Unlocked package app. You will need the Health Cloud Package to be ...
Mohith Shrivastava's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible