Second-Generation Managed Packaging Developer Guide
Workflow for Second-Generation Managed Packages
Use the CLI to Install a Second-Generation Managed Package
Use a URL to Install a Second-Generation Managed Package
Install Notifications for Unauthorized Managed Packages
Upgrade a Second-Generation Managed Package Version
Resolve Apex Test Failures
Customize Second-Generation Managed Package Installs and Uninstalls Using Scripts
Sample Script for Installing Second-Generation Managed Packages with Dependencies
Uninstall a Second-Generation Managed Package
Best Practices for Second-Generation Managed Packages
Gaps Between First-Generation and Second-Generation Managed Packaging
Newer Version Available
Install and Uninstall Second-Generation Managed Packages
Use a disposable scratch org to test your second-generation managed packages (managed
2GP). You can install or uninstall a managed 2GP package using a Salesforce CLI command, or from
the Setup page. Because you can't upgrade a beta package version, be sure you don't install it in
a sandbox that you use in your release pipeline, such as UAT or staging.
-
Use the CLI to Install a Second-Generation Managed Package
If you’re working with the Salesforce CLI, you can use the sf package install command to install packages in a scratch org or target subscriber org. -
Use a URL to Install a Second-Generation Managed Package
Install a second-generation managed package from a browser. -
Install Notifications for Unauthorized Managed Packages
When you distribute a managed package that AppExchange Partner Program hasn’t authorized, we notify customers during the installation process. The notification is removed after the package is approved. -
Upgrade a Second-Generation Managed Package Version
A package upgrade occurs when you install a new package version into an org that has a previous version of that package installed. -
Resolve Apex Test Failures
Package installs or upgrades may fail for not passing Apex test coverage. However, some of these failures can be ignored. For example, a developer might write an Apex test that makes assumptions about a subscriber's data. -
Run Apex on Package Install/Upgrade
App developers can specify an Apex script to run automatically after a subscriber installs or upgrades a managed package. This script makes it possible to customize the package install or upgrade, based on details of the subscriber’s organization. For instance, you can use the script to populate custom settings, create sample data, send an email to the installer, notify an external system, or kick off a batch operation to populate a new field across a large set of data. For simplicity, you can only specify one post install script. It must be an Apex class that is a member of the package. -
Customize Second-Generation Managed Package Installs and Uninstalls Using Scripts
Customize a second-generation managed package (managed 2GP) install or upgrade by specifying an Apex post install script to run automatically after a subscriber installs or upgrades a managed 2GP package. You can also specify an Apex uninstall script to run automatically when a subscriber uninstalls a managed 2GP package. -
Sample Script for Installing Second-Generation Managed Packages with Dependencies
Use this sample script as a basis to create your own script to install second-generation managed packages with dependencies. This script contains a query that finds dependent packages and installs them in the correct dependency order. -
Uninstall a Second-Generation Managed Package
You can uninstall a second-generation managed package from an org using Salesforce CLI or from the Setup UI. When you uninstall second-generation managed packages, all components in the package, including any deprecated components that were previously associated with the package, are deleted from the org.