Developer Controlled Packages (Spring’18 Open Beta)

Manjot Singh
Salesforce-Lightning
4 min readFeb 10, 2018

With Spring 18 release there are many exciting features coming on Salesforce platform. One feature that got my attention is Developer Controlled Packages (DCP). DCP will be Packaging tool for orgs.

Salesforce has released Dx in Winter 18. Now taking DX for customers to next level they had released Developer Controlled Packages. DCPs will help customers to organize metadata in your org

Now lets look at a customers org meta data.

In most of orgs the unpackaged metadata will be scattered. Even though there are groups of Metadata that forms a part specific functionality, with DCPs you can do excatly that. You can group your metadata in a DCP then iterate over DCPs version to update your functionalities.

How to create DCP

  • First you need to create a package.xml for all metadata files you want to add in package.xml
  • Now you have to retrieve files from your org using Package.xml.

sfdx force:mdapi:retrieve -r ./mdapipkg -u <username> -k ./package.xml

  • Once retrieve is complete we can unzip the retrieved files

unzip <package.zip location>

  • After unziping , we convert folder strucutre to dx form

sfdx force:mdapi:convert -r <path to source> -d <path to outputdir>

  • Now we can create a DCP

sfdx force:package2:create -n PackageName -d <PackgeDIscription>-o Unlocked -e

  • After running above command you will get a package Id.
  • We have to copy paste this id in sfdx-project.json. (Salesforce will automate this in next release)
  • Now we will create a package version

sfdx force:package2:version:create -d <PackageName>

  • Creation of package version takes some time. We can monitor progress of package using

sfdx force:package2:version:create get -i <PackageVersionId>

  • After package creation is completed we can install DCP in our org

sfdx force:package:install — id <PackageVersionId> -u <username>

After that we go to our org and see installed packages

Now as you might have a question, first we retrieved all the files from org and then installed DCP in same org (with same files). So what did change? Now all those files have become the part of this DCP. You can open this DCP like any other install Package and see all the components in this Package.

Another important thing about DCP is Dependency Management. Like if you Have some custom/standard objects that are being used in multiple DCPs then you can create an additional package for these metadata’s.

This is how DCP’s life cycle will look like.

  • If new request comes for enchancements then create a scratch org with package metadata. Do changes in that org
  • Run CI and UAT in sandbox and iterate over it.
  • Then Deploy new Version to your production org. Interseting thing about DCP versions is that we can rollback DCP to previous version. That is something which cannot be done in other installed Packages. Also adding and removing Components from DCP is very easy.

So that is all what we have in Spring’18 release for DCP.

Refrences :-

--

--