Use Case: I created a custom object in a customer's environment in which I would now want to tie it as an installed package.

Essentially, a way to go backwards. Typically, you would deploy object to a target org via an unmanaged package, but if the custom objects were manually created, I would like to somehow associate that to a package. Is this possible without deleting the object and deploying it back in via an unmanaged package?

2 Answers 2


Not for a First Generation Unmanaged Package. They cannot be "partial" packages, will automatically fail installation if any component matches the target org's components, and can never be upgraded. What you can do, however, is use an Unlocked Package. Unlike First Generation Unmanaged Packages, they can overlap unpackaged components in a target org, can be "partial" packages (e.g. missing definitions to be filled in by the target org), and can be safely uninstalled or upgraded without deleting the components in the target org.

  • appreciate the answer as always! After doing some research it is my understanding that with an unlocked package you would deploy it via the CLI correct? Additionally, it is my understanding that if the unlocked package had metadata components that already exists in the target org, the package is still deployable (as this is one of the biggest pain points I have with unmanaged packages).
    – andrew
    Nov 23, 2022 at 19:49
  • @andrew (a) They can be installed both through the CLI as force:package:install and in the UI (there's an install URL, just like other types of packages). (b) Yes, those components will become part of the Unlocked Package. When you uninstall, those elements will be marked as 'deprecated' but not deleted, so uninstalls are safer than First Generation Packages and Managed Packages as well.
    – sfdcfox
    Nov 23, 2022 at 19:51
  • Thank you for the quick response! From what I learned with Unmanaged Packages, and carrying that over to unlocked packages, in the CLI I am able to create a project and authorize my org, but since Unlocked Packages don't use a package.xml file to define what metadata components you want to pull from the source org and package up to a target org, what method does an unlocked package use instead? Is this where the scratch org comes into place? Hope my question makes sense!
    – andrew
    Nov 23, 2022 at 20:09
  • @andrew You use force:source:retrieve against the original dev org with -x to use a package.xml, -n PackageName to retrieve a package, or -m to retrieve specified artifacts. VS Code can also help you retrieve the metadata you want. Scratch orgs can be used for development instead of dev orgs or sandboxes, and can use force:source:push and force:source:pull to sync changes you make locally or in the org.
    – sfdcfox
    Nov 23, 2022 at 20:26

You can use the unlocked packages to achieve what you need. You will move the object to an unlocked package.

Once you create an unlocked package, install the package in the org. This installation does not deploy new metadata as what’s contained in the package is already present in the production org. But what this does is migrate the metadata from the unpackaged set to the package so that it is now part of the package in the production org.

  • 3
    Five seconds, lol.
    – sfdcfox
    Nov 8, 2022 at 0:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .