To create a feature parameter for a 2GP managed package, create an individual XML file. Here are details on the file naming convention, folder structure, and the attributes you use when creating feature parameters.
note: Feature parameters for managed 1GP packages are created in the packaging org’s UI, see Create Feature Parameters in Your Packaging Org in the First-Generation Managed Packaging Developer Guide for details.
A package can include up to 200 feature parameters.
Folder Structure
Feature parameters are stored as files in your Salesforce DX project folder.
Under the root force-app folder, create a folder and name it featureParameters. Store your feature parameter files in the feature parameters folder. Each feature parameter you create must have its own separate file.
note: It’s not possible to create feature parameters using a scratch org’s user interface.
File Naming Convention
The naming format for feature parameter files is <name>.featureParameter<type>-meta.xml.
The name is the API name of the feature parameter.
The type is the feature parameter type. Feature parameters can be booleans, integers, or dates.
| Type | File Name Format |
|---|---|
| Boolean | .featureParameterBoolean-meta.xml |
| Date | .featureParameterDate-meta.xml |
| Integer | .featureParameterInteger-meta.xml |
Feature Parameter Attributes
Feature parameters include these three fields.
| Field Name | Description |
|---|---|
| dataflowDirection | Indicates which direction this parameter is transferring data. Each feature parameter value gets transferred in one of two directions: from your LMO to a subscriber org (LmoToSubscriber), or from a subscriber org to your LMO (SubscriberToLmo). |
| masterLabel | The label of the feature parameter. This label displays in the app. |
| value | The value of the feature parameter. Booleans, integers, and dates are all valid values. Integer values can’t exceed nine digits. |
note: After a feature parameter is included and released in the package version, the data flow direction can’t be changed.
Examples of Feature Parameter file
AdvancedPricingEnabled.featureParameterBoolean-meta.xml
<FeatureParameterBoolean xmlns="http://soap.sforce.com/2006/04/metadata">
<dataflowDirection>SubscriberToLmo</dataflowDirection>
<masterLabel>Advanced Pricing Enabled</masterLabel>
<value>true</value>
</FeatureParameterBoolean>
NumberofLedgers.featureParameterInteger-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<FeatureParameterInteger xmlns="http://soap.sforce.com/2006/04/metadata">
<dataflowDirection>SubscriberToLmo</dataflowDirection>
<masterLabel>Number of Ledgers</masterLabel>
<value>7</value>
</FeatureParameterInteger>
ProjectActivationDate.featureParameterDate-meta.xml
<?xml version="1.0" encoding="UTF-8"?>
<FeatureParameterDate xmlns="http://soap.sforce.com/2006/04/metadata">
<dataflowDirection>LmoToSubscriber</dataflowDirection>
<masterLabel>Date of Activation of the Project</masterLabel>
<value>2020-01-25</value>
</FeatureParameterDate>