Hide Custom Objects and Custom Permissions in Your Subscribers’ Orgs

Occasionally, you want to include custom permissions or custom objects in a package but not show them to your subscribers. For example, if you're piloting a feature for a few select orgs, and want to hide custom permissions and custom objects related to the pilot feature.

Check with your company’s legal team before releasing hidden functionality.

Note

To hide custom objects when creating your package, set the value of their Visibility field to Protected. After you've set the visibility to Protected, you can later update it to Unprotected. To change the visibility of an object, use the CustomObject Metadata API and update the visibility field.

To hide custom permissions when creating your package, from Setup, enter Custom Permissions in the Quick Find box. Select Custom Permissions | Your Custom Permission | Edit. Enable Protected Component, and then click Save. After your package is installed, use the System.FeatureManagement.changeProtection() Apex method to hide and unhide custom objects and permissions.

After you’ve released unprotected objects to subscribers, you can’t change the visibility to Protected.

Warning

To hide custom permissions in released packages:
  • System.FeatureManagement.changeProtection('YourCustomPermissionName', 'CustomPermission', 'Protected');
To unhide custom permissions and custom objects in released packages:
  • System.FeatureManagement.changeProtection('YourCustomPermissionName', 'CustomPermission', 'Unprotected');
  • System.FeatureManagement.changeProtection('YourCustomObjectName__c', 'CustomObject', 'Unprotected');