2

When an Unlocked Package is installed into a subscriber org, the metadata from the package is tagged as belonging to the package.

In that subscriber org, we can go to the package details through the Setup UI, view the list of components, and remove some of them from the ownership of the package.

One use-case is to transfer a metadata item from package to another.

But, is there a programmatic way to achieve the same thing?

I've seen this question before here: Remove component from Unlocked Package programmatically

But my question is not a duplicate. The accepted answer is just about transferring from one package to another. There are other use-cases where creating a package version excluding the metadata that we want to remove is not appropriate.

The other use-cases include:

  • Releasing the metadata to be managed in the org, not by any package. Installing a version which excludes the metadata item there ends up marking it as deprecated forever
  • Having two packages with overlapping metadata where only one of them will be installed at a time, and a subscriber org decides to migrate from one package to another
  • Working around bugs in 2GP where it claims there are metadata clashes when the metadata is in-fact all from the same package

So: Is there a programmatic way to remove metadata from an Unlocked Package other than installing a new version of the same package?

1

AFAIK, the only way to do that programmatically is through installing a new version of the package with mixed or delete as the UPGRADETYPE option. The other way to go through the UI and remove it and then manually delete the components using a puppeteer script ( we tried this, but it was too brittle). So in our current mode of working, we preserve an ID of a very early version of package which has very.little components and when these kind of usecase come up, we use that to deprecate the package and install the new one

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.