# Create a Managed Package for Enablement Programs, Measures, and Content

To package Enablement programs and their dependencies, set up your source org environment and project settings for Enablement data, retrieve the appropriate metadata, and create the package.

:::tip
Before you create a package, review the [considerations for packaging Enablement programs and dependencies](/docs/sales/enablement/guide/enablement-package-considerations.md).
:::

## 1. Specify Features and Metadata in Your Project

In your Salesforce DX project, add the required scratch org features and settings, and retrieve the metadata related to the programs that you want to package.

1. Set up your source org for creating second-generation managed packages.

   To learn about setup options, see [Second-Generation Managed Packages](https://developer.salesforce.com/docs/atlas.en-us.pkg2\_dev.meta/pkg2\_dev/sfdx_dev_dev2gp.htm) in the *Second-Generation Managed Packaging Developer Guide*.

2. In your scratch org definition file, include these scratch org features and settings that you need for programs.

   See [Build Your Own Scratch Org Definition File](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file.htm) in the *Salesforce DX Developer Guide*.

   For all programs, include the scratch org features `GuidanceHubAllowed` and `Enablement`.

   ```json
   {
     "features": ["GuidanceHubAllowed", "Enablement"]
   }
   ```

   If the program contains a Feedback Request exercise that references an assessment survey, also include the `SurveyAdvancedFeature` scratch org feature. `SurveyAdvancedFeature` requires the SurveySettings where `enableSurvey` is `true` . The SurveySettings must be included in the the scratch org definition file.

   ```json
   {
     "features": ["GuidanceHubAllowed", "Enablement", "SurveyAdvancedFeatures"],
     "settings": {
       "SurveySettings": {
         "enableSurvey": true
       }
     }
   }
   ```

   If the program is for Partner Enablement in an Experience Cloud site, also include the scratch org features `EnablePRM` and `Communities`. `Communities` also requires the CommunitiesSettings scratch org setting where `enableNetworkEnabled` is `true`.

   ```json
   {
     "features": ["GuidanceHubAllowed", "Enablement", "Communities", "EnablePRM"],
     "settings": {
       "CommunitiesSettings": {
         "enableNetworkEnabled": true
       }
     }
   }
   ```

3. Retrieve these metadata types for the Enablement programs and dependencies that you want to package.

   - [EnablementProgramDefinition](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_enablementprogramdefinition.htm)
   - [EnablementMeasureDefinition](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_enablementmeasuredefinition.htm), if a program includes an outcome and milestones that reference Enablement measures
   - [Flow](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_visual_workflow.htm), if a program includes a Feedback Request exercise that references an assessment survey

   Include this entry in your `package.xml` file.

   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <Package xmlns="http://soap.sforce.com/2006/04/metadata">
       <types>
           <members>*</members>
           <name>Flow</name>
       </types>
       <version>62.0</version>
   </Package>
   ```

   - [Network](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_network.htm), if a program is for Partner Enablement in an Experience Cloud site
   - [DigitalExperienceBundle](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_digitalexperiencebundle.htm), if a program includes exercise content from the Enablement workspace in the Digital Experiences app

   Retrieve content only from the Enablement workspace. Don't retrieve content from other workspaces. Include this entry in your `package.xml` file.

   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <Package xmlns="http://soap.sforce.com/2006/04/metadata">
       <types>
           <members>enablement/sfdcEnablement_EnablementWorkspace</members>
           <name>DigitalExperienceBundle</name>
       </types>
       <version>62.0</version>
   </Package>
   ```

   :::note
   Because only content with a status of Published can be used in a program, all content included in the package is set to Published when the package is installed. This is different behavior from when you package Digital Experiences content outside the Enablement workspace, where you can package and deploy content of other statuses. When you retrieve content to include in a package, take care to retrieve only the content from the Enablement workspace.
   :::

4. In your Salesforce DX project’s `force-app/main/default` directory, verify that you have these folders for the metadata components that you’re including in the package.
   - `enablementProgramDefinitions`
   - `enablementMeasureDefinitions`, if a program includes an outcome and milestones that reference measures
   - `flows`, if a program includes a Feedback Request exercise that references an assessment survey
   - `networks`, if a program is for Partner Enablement in an Experience Cloud site
   - `digitalExperienceBundles`, if a program includes exercise content from the Enablement workspace in the Digital Experiences app

## 2. Retrieve Metadata for Custom Exercise Types

If a program includes custom exercise types, retrieve additional required metadata types and include them in your project. See [Create Custom Exercises for Enablement Programs](/docs/sales/enablement/guide/enablement-custom-exercises-intro.md).

1. Retrieve these metadata types.
   - [ApexClass](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_classes.htm), for the evaluation handler, serializer, and deserializer classes associated with a custom exercise type
   - [CustomObject](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/customobject.htm), for the custom object associated with a custom exercise type
   - [CustomField](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/customfield.htm), for the custom field on the LearningItem object
   - [EnblProgramTaskSubCategory](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_enblprogramtasksubcategory.htm) and [LearningItemType](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_learningitemtype.htm), for the custom exercise definitions in Program Builder and Guidance Center, respectively
   - [LightningComponentBundle](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_lightningcomponentbundle.htm), for the custom Lightning web components associated with a custom exercise type
2. In your Salesforce DX project’s `force-app/main/default` directory, verify that you have these folders for the metadata components that you’re including in the package.
   - `classes` for Apex classes
   - `objects` for the standard object LearningItem with a custom field and the custom object
   - `enblProgramTaskSubCategories`
   - `learningItemTypes`
   - `lwc` for the Lightning web components

## 3. Modify the Retrieved Metadata for Digital Experiences Content

In your project, update the retrieved metadata for Digital Experiences content related to program exercises, and update the program metadata that references that content.

1. In the `digitalExperienceBundles` folder, change the name of the workspace that’s installed in the destination org. Because the destination org has an Enablement add-on license, the destination org also has the default Enablement workspace with the `sfdcEnablement_EnablementWorkspace` API name. To avoid conflicts with that default namespace in the destination org, specify a unique name and API name for the workspace that the package installs.
   1. Change the value of `<label>` to a unique workspace name.
   2. Change the value of `<description>` to a new description of the workspace.
   3. In `sfdcEnablement_EnablementWorkspace.digitalExperience-meta.xml`, change the `sfdcEnablement_EnablementWorkspace` portion of the filename, which is the API name of the Enablement workspace in the source org. For example, to use the custom workspace API name `customWorkspaceName`, rename the file to `customWorkspaceName.digitalExperience-meta.xml`.
2. In the `enablementProgramDefinitions` folder, update the retrieved program metadata to reference Digital Experiences content by the new workspace API name.

   For example, let's say that an EnablementProgramDefinition component includes this reference to a Link content record.

   ```xml
   <exercise>
    <cmsContent>
      <apiName>enablement/sfdcEnablement_EnablementWorkspace.sfdc_enablement__link/MCFHN7EKKKUJBOPLXMJWZ7XWK3LA</apiName>
    </cmsContent>
   </exercise>
   ```

   Replace the default workspace API name with the custom workspace API name that you specified.

   ```xml
   <exercise>
    <cmsContent>
      <apiName>enablement/customWorkspaceName.sfdc_enablement__link/MCFHN7EKKKUJBOPLXMJWZ7XWK3LA</apiName>
    </cmsContent>
   </exercise>
   ```

:::tip
The `<apiName>` element is used when you retrieve program metadata in API version 62.0 and later.

If you retrieved program metadata in API version 61.0, the program’s references to Digital Experiences content use the `<contentKey>` element instead. Update these references so that they use the `<apiName>` value, and include the custom workspace API name.
:::

## 4. Finalize Your Project

Specify the required permissions in your project file, then create, test, and promote your package.

1. Update your Salesforce DX project file to include the required permission set licenses for accessing the metadata types.

   ```json
   {
     "packageMetadataAccess": {
       "permissionSets": ["EnablementAdmin"],
       "permissionSetLicenses": ["EnablementPsl"]
     }
   }
   ```

2. Create a package version. To include the appropriate features in the destination org, reference the scratch org definition file you created. Add the `definitionFile` parameter in your project configuration file, or use the `--definition-file` flag from the command line.

3. Test and verify the package.

4. Promote the package to released status.

**See Also**

- *Salesforce DX Developer Guide*: [Scratch Orgs](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs.htm)
- *Second-Generation Managed Packaging Developer Guide*: [Project Configuration File for a Second-Generation Managed Package](https://developer.salesforce.com/docs/atlas.en-us.pkg2\_dev.meta/pkg2\_dev/sfdx_dev2gp_config_file.htm)
- *Salesforce CLI Command Reference*: [package Commands](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_package_commands_unified.htm)
