Set Up And Manage Packages In A Scratch Org Using Salesforce DX.

Numerous useful SFDX commands exist to automate Salesforce deployment. However, a crucial aspect of Salesforce DX is the ability to set up an org within minutes, complete with features like Person Account and Communities enabled.

At times, these commands may not suffice. I recently encountered such a situation where I needed to install and manage a package for a quick capability check. Despite scanning through documentation and Stack Exchange, I struggled to automate the package installation process. While there are several commands for installing second-generation packages, managing packages directly proved challenging. Fortunately, I discovered Marty Chang’s GitHub repository, which provided the necessary instructions.

Here is the process:

  • Create a folder named “installedPackages” in the “force-app/main/default” directory.
  • For this blog post, we will be installing Salesforce CPQ. Place the following file in the “installedPackages” folder with the name “SBQQ.installedPackages-meta.xml”.
<?xml version="1.0" encoding="UTF-8"?>
<InstalledPackage xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <activateRSS>false</activateRSS>
    <versionNumber>216.10.1</versionNumber>
</InstalledPackage>

As evident, the file naming convention follows the format <managepackagenamespace>.installedPackages-meta.xml.

For instance, in the case of Field Service Lightning, the file name would be FSL.installedPackage-meta.xml.

<?xml version="1.0" encoding="UTF-8"?>
<InstalledPackage xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <activateRSS>false</activateRSS>
    <versionNumber>4.0.17</versionNumber>
</InstalledPackage>

An illustration of B2B Commerce Cloud would be the file named ccrz.installedPackage-meta.xml.

<?xml version="1.0" encoding="UTF-8"?>
<InstalledPackage xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <activateRSS>false</activateRSS>
    <versionNumber>3.133.2</versionNumber>
</InstalledPackage>