Newer Version Available
Remove Metadata Components from Second-Generation Managed Packages (Pilot)
We provide Remove Metadata Components from 2GP to selected customers through a pilot program that requires agreement to specific terms and conditions. To be nominated to participate in the program, contact Salesforce. Pilot programs are subject to change, and we can’t guarantee acceptance. Feature isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for Remove Metadata Components from 2GP in the Managed Packages group in the Partner Community.
Impact of Component Removal in Subscriber Orgs
During package upgrade only certain component types are hard deleted and removed from the subscriber org. Most metadata components that were removed in a package version, will remain in the subscriber org after package upgrade, and marked as deprecated. When a package is upgraded in the subscriber org, the Setup Audit Trail logs which components were removed. Admins of a subscriber org can delete deprecated metadata.
This pilot supports the removal of the following metadata components from second-generation managed packages.
| Metadata Component | Upon Package Upgrade, the Metadata Component is ... |
|---|---|
| Apex Class (excluding global Apex classes) | Hard deleted |
| Apex Trigger | Hard deleted |
| Aura Definition Bundle | Marked as deprecated |
| Compact Layout | Marked as deprecated |
| Custom Application | Marked as deprecated |
| Custom Field | Marked as deprecated |
| Custom Object | Marked as deprecated |
| Custom Tab | Marked as deprecated |
| Field Set | Marked as deprecated |
| Layout | Marked as deprecated |
| List View | Marked as deprecated |
| Permission Set | Marked as deprecated |
| Quick Action | Marked as deprecated |
| Record Type | Marked as deprecated |
| Sharing Reason | Marked as deprecated |
| Static Resource | Marked as deprecated |
| Validation Rule | Marked as deprecated |
| Visualforce Component (excluding global components) | Hard deleted |
| Visualforce Page | Marked as deprecated |
| WebLink (Custom Button or Custom Link) | Marked as deprecated |
How to Remove Metadata Components
To join this pilot, log a case at https://partners.salesforce.com/partnerSupport.
After the pilot is enabled, remove the metadata component’s source file from your Salesforce DX project, and create a new package version. Test the new package version to ensure it’s working properly without the removed metadata.
Before You Remove Metadata Components from Second-Generation Managed Packages
To ensure you can successfully remove metadata components from a second-generation managed package, keep these details in mind.
- Request access to the pilot, if you haven’t already.
- Familiarize yourself with the list of metadata components that can be removed.
- Ensure that there aren’t dependencies on the metadata you plan to remove.
Remove Metadata Dependencies Within a Package
If there are dependencies to the metadata component you plan to remove, first resolve the dependency before removing the metadata component.
For example, before deleting a custom field that is referenced in a page layout, edit the page layout and remove the reference to the custom field. Then remove the custom field from your source file, and create a new package version.
Some scenarios require a two-step approach to component removal. For example, if you plan to remove a Visualforce page that contains a Visualforce component, and replace it with a Lightning page that contains a Lightning component, removing both the Visualforce page and Visualforce component in a single upgrade could cause issues for your subscribers. These issues occur because Visualforce components are deleted, and Visualforce pages are deprecated during package upgrade.
To avoid issues for your subscribers in this example, remove the reference to the Visualforce component from the Visualforce page, create a new package version and push the upgrade. Then remove the Visualforce page from your package version, and push this upgrade to subscribers.
Remove Dependencies Located in Other Packages
Before you remove a metadata component, first remove all references to the metadata, including references in other packages that depend on that metadata component. For example, if you’re removing a public Apex class, ensure your other packages aren’t referencing that class using the Apex @namespaceAccessible annotation.
In this section, PackageA refers to the package in which you plan to remove a metadata component. And PackageB is any package that depends on the metadata you’re removing from PackageA. If you have references to the metadata component or Apex class in PackageB, follow these steps:
- Remove the reference to the metadata component from PackageB.
- Create a new version of PackageB.
- Push the new version of PackageB to your subscribers.
- Repeat these steps if any other packages include a reference to the metadata you plan to remove from PackageA.
After all references to the metadata component have been removed, remove the metadata component’s source file from the Salesforce DX project of PackageA, and create a new version of PackageA. Before pushing this upgrade to subscribers, test the new package version to ensure it’s working properly.