Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, 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.
Hide Custom Objects and Custom Permissions in Your Subscribers’ Orgs
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 . 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.
- System.FeatureManagement.changeProtection('YourCustomPermissionName', 'CustomPermission', 'Protected');
- System.FeatureManagement.changeProtection('YourCustomPermissionName', 'CustomPermission', 'Unprotected');
- System.FeatureManagement.changeProtection('YourCustomObjectName__c', 'CustomObject', 'Unprotected');