Hot answers tagged

26

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 to Get the LMA to "see" a Second-Generation Managed Package PART THREE: Technical Enablement for Second-Generation Extension Packages Not gonna lie, ...


8

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 your Packaging Org enabled to pilot the functionality: https://partners.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F94V000000PkSm Previous Answer (...


6

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 documentation covering this, I've reproduced here what I posted on the Partner Forums after weeks of slow progress. To succeed in creating a no-namespace, unlocked ...


5

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 use a new Developer Edition org, then to link that namespace to your dev hub. For us we use a specific pattern for the org name to ensure they are listed in our ...


5

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 has also been a practice in 1GP Managed package application before and is the right strategy to use the same approach for the Unlocked package and 2GP Managed ...


5

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 unfortunate downside of potentially complicating issues, but the general format that I came up with, which seems to work okay, involves a three layered approach to the ...


5

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 plan to add this ability in the future according to webinars and presentations around 2GP. Your solution, therefore, is to add back in the ExampleCtrl class to ...


5

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 create patch releases for a 2GP managed package.) Publishing 2GPs on the AppExchange is explicitly covered in the documentation, as is dealing with 2GP ...


4

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 features in its definition file, which is provided to force:package:version:create with the [-f DEFINITIONFILE] argument. You can potentially reuse an existing scratch ...


4

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 that was never installed will fail to deploy. This creates a big cat-and-mouse type problem for subscribers of these packages. To minimize this disruption, ...


4

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 and install your packages in there. Namespaced scratch orgs should be used for development work on a package. Non-namespaced scratch orgs should be used for ...


4

So in Apex Tests, you can use the RunAs feature to do this - basically, create a user in the test, assign a basic profile (the new Minimum Access one is helpful for this), and then assign the permission set, and run the test e.g. Profile p = [SELECT Id FROM Profile WHERE Name = 'Minimum Access - Salesforce ']; User u = new User(Alias = 'standt', Email = '...


4

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, but this makes sense; ISVs need to be able to push out updates, sometimes forcefully (see Push Upgrades), which wouldn't be possible if a user could just ...


4

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 taken to, upon the completion of the installation process. Unlike 1GP, in 2GP, we only support the URL and NOT the VF page. This is something that fell below ...


4

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 and scratch org definition. Just because you find suggestions as to how to achieve certain things, such as including profiles and sharing sets in the unlocked ...


4

Do I have to create a scratch org to be able to use 2GP? Yes, 2GP packages are completely developed in scratch orgs. Or can I create my changes in the SF developer org, test, and push to production org, pull down prod changes to VSCode and run the sfdx cli commands to push to a beta package? 2GPs do not use a "production org". A developer ...


4

This is currently a Known Issue. There is no feasible resolution you can undertake. It's related to Custom Fields on Custom Metadata Types. My understanding, as of 2021-07-26, is that this issue is likely to be patched in the next few days. I am a Salesforce employee but am not on the team working on this issue; this is not an official statement or ...


3

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 installed in scratch org for this and you need below in your project sfdx-project.json file. Here "04t..." will be the latest Health cloud package ID. Check ...


3

Just to add to this, it definitely use to be an issue in 1GP packages, which is why you see posts about it. I think it was Dan Appleman who suggested using this pattern in scheduled jobs to avoid that issue, and I still use it today. So I think sfdcfox is correct that managed packages basically install as if "Allow deployments of components when ...


3

Summarizing comments: Second-generation packaging currently does not allow deletion of managed components of any type. It's on the list at Gaps Between First-Generation and Second-Generation Managed Packaging: Components can’t be deleted from packages. While the page states We’re working to address these feature gaps. I'm not aware of an accepted Idea or ...


3

I worked with a colleague on this. The answer was to create the new package version as 1.1.0-1. For some reason, using 1.0.3.0 was not accepted. Having the beta version number be something other than zero was the answer.


3

Communities are not packageable for 2GP packages. As an unlocked package yes you can package up the ExperienceBundle (there are some known issues with ExperienceBundle as well on known issue site so do not recommend it as of today) but not as a 2GP yet. The only recommended way to package communities is via the "Bolt Solution" which allows you to ...


3

Important release notes from Salesforce - Spring 21 onwards After your Dev Hub org is updated to the Spring ’21 release, you can create packages with the release version set to previous. Starting in the Summer ’21 release transition, you can specify preview or previous as the release version. How: To create a package version based on the previous Salesforce ...


3

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 this doesn't work when combined with the ExperienceBundle, and it will throw this (nondescript) error.


3

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 enabled. Setup > Communities Settings > Enable ExperienceBundle Metadata API We don't know why and it even worked after we disabled it.


3

The Metadata Coverage Report is the best source for which components are packageable in 1GP ("Classic Packaging") and 2GP ("Managed Packaging"). What you're referring to are not metadata components, though, but elements of components. The references for specific component behaviors are the ISVforce Guide and the Metadata API Reference. ...


3

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 has a dev hub, that owns all our 1GP enterprise managed/unmanaged packages. Dev Hubs do not own 1GP managed packages - the packaging org does. Your Dev Hub ...


3

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. { "packageDirectories": [ { "path": "force-app", "default": true, "package":...


2

There does exist a feature as shown in the Dreamforce video you reference that allows creation of a scratch org from a TSO Template Id via the "template" key. This feature is not currently GA. I reached out to the team internally that owns this feature and confirmed that it is not typically available to customers even by request.


2

Salesforce has answered my question: This is to share that packaging org where the package is developed inherits the feature of the current release. In your situation, DevHub is in Summer 20, where the package was developed and released and thus when you will try to install the same package in older version, it fails. So as shared, you shall be able to ...


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