Sub topic 4
Managed versus unmanaged packages
This chapter assumes you know basic Salesforce administration (Setup, profiles, permission sets) and the difference between a sandbox and production. By the end, you should be able to tell which kind of package a listing offers and predict how it will behave when you upgrade, customize, or remove it.
Why package type matters for safety
A package is a container of metadata (objects, fields, Apex code, flows, page layouts) that you install into your org. The package type decides three things that affect risk:
- Who can see and change the contents.
- Whether the publisher can ship fixes to you.
- How cleanly you can remove the app.
Check the type before you install, because you cannot convert one type into the other after the fact.
Managed packages
A managed package is owned and maintained by the publisher. Salesforce tracks it with a namespace prefix, a short unique string added to the names of the package's components. For example, a custom object might appear as acme__Invoice__c.
Key behaviors:
- Protected code. Apex code in a managed package is hidden from you. You can see that it exists, but you cannot read or edit it.
- Upgrades. The publisher releases new versions. You install them over the existing version, and your data and your own customizations stay in place.
- Locked components. You cannot delete or restructure most of the package's components. You can often change labels or page layouts, within limits the publisher sets.
- Licensing. Publishers can control licenses, so they can limit the number of users or expire a trial.
- Security Review. Managed packages that are listed on AppExchange go through the Security Review. The next chapter explains what that covers.
The hidden code is a trade-off. It protects the publisher's work, but it means you cannot audit the logic yourself. You rely on the publisher and the review process.
Unmanaged packages
An unmanaged package is a one-time copy of metadata. After installation, the components belong to your org as if you had built them yourself.
Key behaviors:
- Open code. You can read and edit everything, including Apex.
- No upgrades. The publisher cannot push a new version into your org. To get changes, you install a new copy, which can create duplicate components or conflicts.
- No namespace. Components have no prefix, so names can collide with your existing ones.
- No license control. The publisher has no ongoing link to your installation.
- Removal is manual. You delete each component yourself, and dependencies can block deletion.
Unmanaged packages suit templates and sample code, where you expect to change things. They are a weaker fit for apps you want to keep patched.
Comparing the two
| Aspect | Managed | Unmanaged |
|---|---|---|
| Code visibility | Hidden from subscribers | Fully visible and editable |
| Upgrades from publisher | Yes, in place | No, install a new copy |
| Namespace | Yes | No |
| License control | Publisher can manage | None |
| Uninstall | One action removes the package | Delete components one by one |
| Audit by your team | Limited to settings and behavior | Full code review possible |
Seeing the difference in your org
After installing in a sandbox, list installed packages with the CLI:
sf package installed list --target-org my-sandboxManaged packages appear in this list with a namespace and a version number. Unmanaged packages do not show up as installed packages in the same way, because Salesforce keeps no live link to them.
In Setup, search for Installed Packages. Managed entries show the publisher, version, and license status. Unmanaged components appear under their normal metadata types, so you must look for them there.
Common errors
- Assuming an unmanaged package gets fixes. It does not. If a security flaw is found, you must apply the fix yourself.
- Editing an unmanaged component and then reinstalling. A second install can overwrite or duplicate your changes.
- Ignoring dependencies. Your own flows, reports, or code may reference a package component. Salesforce blocks removal until you remove those references.
- Treating hidden code as proof of safety. Hidden code is not audited by you. Rely on listing signals and review results, covered in the neighboring chapters.
A practical rule
Prefer a managed package from a credible publisher when you want ongoing support and upgrades. Accept an unmanaged package only when you plan to own and review the components, and always try it in a sandbox first.
Exercise
Your team needs a sample Apex trigger from a vendor to adapt for your own process. The vendor offers it as an unmanaged package. A different vendor offers a full invoicing app as a managed package. For each one, say who is responsible for fixing a future bug and how you would remove it.
Show answer
For the unmanaged trigger, your team is responsible for fixes, because the code is a copy in your org and receives no upgrades. You remove it by deleting each component yourself after clearing any dependencies. For the managed invoicing app, the publisher ships fixes as new package versions that you install over the current one, and you remove the whole app with a single uninstall action (after resolving dependencies and handling its data).