FeatureManagement Class

Use the methods in the System.FeatureManagement class to check and modify the values of feature parameters, and to show or hide custom objects and custom permissions in your subscribers’ orgs.

Namespace

System

Usage

For information about feature parameters, see “Get Started with the Feature Management App” in the ISVforce Guide.

FeatureManagement Methods

The following are methods for FeatureManagement.

changeProtection(apiName, typeApiName, protection)

Hides or reveals custom permissions, or reveals custom objects, in your subscriber’s org.

Signature

public static void changeProtection(String apiName, String typeApiName, String protection)

Parameters

apiName
Type: String
The API name of the custom object or custom permission to show or hide—for example, 'MyCustomObject__c' or 'MyCustomPermission'.
typeApiName
Type: String
The API name of the type that you want to show or hide: 'CustomObject' or 'CustomPermission'.
protection
Type: String

To show a custom object or custom permission, 'Unprotected'.

To hide a custom permission, 'Protected'.

Return Value

Type: void

Usage

Warning

Warning

For custom permissions, you can toggle the protected value indefinitely. However, after you’ve released unprotected objects to subscribers, you can’t set visibility to Protected. Be sure to protect any custom objects that you want to hide before you release the first package version that contains them.

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

checkPackageBooleanValue(apiName)

Checks the value__c value of the FeatureParameterBoolean__c record for a feature parameter in your subscriber’s org. You set the record’s value using setPackageBooleanValue(apiName, value).

Signature

public static Boolean checkPackageBooleanValue(String apiName)

Parameters

apiName
Type: String
The fullName__c value of the feature parameter whose value you want to check—for example, 'SpecialAccessAvailable'.

Return Value

Type: Boolean

The value that’s currently assigned to the value__c field on the FeatureParameterBoolean__c record that associates the feature parameter with its related license.

checkPackageDateValue(apiName)

Checks the value__c value of the FeatureParameterDate__c record for a feature parameter in your subscriber’s org. You can set the record’s value using setPackageDateValue(apiName, value).

Signature

public static Date checkPackageDateValue(String apiName)

Parameters

apiName
Type: String
The fullName__c value of the feature parameter whose value you want to check—for example, 'TrialExpirationDate'.

Return Value

Type: Date

The value that’s currently assigned to the value__c field on the FeatureParameterDate__c record that associates the feature parameter with its related license.

checkPackageIntegerValue(apiName)

Checks the value__c value of the FeatureParameterInteger__c record for a feature parameter in your subscriber’s org. You can set the record’s value using setPackageIntegerValue(apiName, value).

Signature

public static Integer checkPackageIntegerValue(String apiName)

Parameters

apiName
Type: String
The fullName__c value of the feature parameter whose value you want to check—for example, 'NumberOfLicenses'.

Return Value

Type: Integer

The value that’s currently assigned to the value__c field on the FeatureParameterInteger__c record that associates the feature parameter with its related license.

checkPermission(apiName)

Checks whether a custom permission is enabled.

Signature

public static Boolean checkPermission(String apiName)

Parameters

apiName
Type: String
The API name of the custom permission to check the value of—for example, 'MyCustomPermission'.

Return Value

Type: Boolean

Shows whether the permission is enabled (true) or disabled (false).

setPackageBooleanValue(apiName, value)

Sets the value__c value of the FeatureParameterBoolean__c record for a subscriber-to-LMO feature parameter in your subscriber’s org. You can check the record’s value using checkPackageBooleanValue(apiName).

Signature

public static void setPackageBooleanValue(String apiName, Boolean value)

Parameters

apiName
Type: String
The fullName__c value of the feature parameter whose value you want to set—for example, 'SpecialAccessAvailable'.
value
Type: Boolean
The value to assign to the value__c field on the FeatureParameterBoolean__c record that associates the feature parameter with its related license.

Return Value

Type: void

setPackageDateValue(apiName, value)

Sets the value__c value of the FeatureParameterDate__c record for a subscriber-to-LMO feature parameter in your subscriber’s org. You can check the record’s value using checkPackageDateValue(apiName).

Signature

public static void setPackageDateValue(String apiName, Date value)

Parameters

apiName
Type: String
The fullName__c value of the feature parameter whose value you want to set—for example, 'TrialExpirationDate'.
value
Type: Date
The value to assign to the value__c field on the FeatureParameterDate__c record that associates the feature parameter with its related license.

Return Value

Type: void

setPackageIntegerValue(apiName, value)

Sets the value__c value of the FeatureParameterInteger__c record for a subscriber-to-LMO feature parameter in your subscriber’s org. You can check the record’s value using checkPackageIntegerValue(apiName).

Signature

public static void setPackageIntegerValue(String apiName, Integer value)

Parameters

apiName
Type: String
The fullName__c value of the feature parameter whose value you want to set—for example, 'NumberOfLicenses'.
value
Type: Integer
The value to assign to the value__c field on the FeatureParameterInteger__c record that associates the feature parameter with its related license.

Return Value

Type: void