Friday, October 19, 2018

Salesforce DX - Using Salesforce Developer Org as Developer Hub Org

Salesforce DX is source driven development.The core philosophy of Salesforce DX is that the version control is source of truth. To implement this philosophy, Salesforce has provided short lived orgs called as Scratch Orgs. These orgs can be created very easily and within a short span of time. These Scratch Orgs are connected to a central Org called as "Developer Hub" Org.

During the initial phase of release of Salesforce DX, Salesforce provided facility to enable developer Hub in Production Orgs as well as it provided Developer Hub as a 30 day trial org which can be used by people to try Salesforce DX (https://developer.salesforce.com/promotions/orgs/dx-signup). The disadvantage of this org is that after the trial period, you lose this org as well as all the scratch org associated with it. Developer Edition orgs don't expire as long as they remain active. In a Developer Edition Dev Hub, you can create up to 6 scratch orgs with a maximum of 3 active scratch orgs.

Based on customer feedback and for wider adoption, with the Winter 19 release, Salesforce is now allowing us to enable developer Hub in the developer Org itself.

In this article we will see how to enable the developer Hub in the Winter 19 developer Org.

Start by registering for a winter 19 developer Org. Open https://developer.salesforce.com/signup and register for a developer Org by filling the form.


Once you have the org created, you can login into it and use it for development purpose.


Now to enable the dev hub in the org, click on the gear icon on the top right corner to open the setup menu. Search for Dev Hub in the setup menu. You will see a toggle button with the text as "Enable Dev Hub". Toggle it to enable dev hub in this org.


Once enabled, you cannot disable the setting. Also once this setting is enabled, you will see option to enable packing in the org. We will learn about packing in future blog posts.



Now, we will connect to the developer hub org using the sfdx cli tool. We assume that you have installed the SFDX CLI tool, if not, you can follow this blog post  - https://www.salesforce-vscode.com/2018/10/salesforce-cli-installation.html.

Open command prompt and enter below command
sfdx force:auth:web:login --setdefaultdevhubusername --setalias mydeveloperhuborg

Using this command we are basically opening the developer Hub org, so that it can be used in future for creating scratch orgs. Here the alias name is set to mydeveloperhuborg.
Once you run this command you will be prompted for providing the permission so that the SFDX CLI tool can connect to the org. Once the authorisation is complete, you will see success message in the command prompt.


Let us now create a simple lightning app so that we can group the Salesforce DX, Scratch Org related tabs.



Create a new lightning app. Lets give it a name of "Developer Hub". Include DX related tabs like "Active Scratch Orgs, "Scratch Org Infos" and "Namespace Registries".



You will now be able to see the scratch org information grouped in this app. Currently there are none in the screen shot as we have not created any. We will see how to create scratch orgs and link it with this org in the next blog post.


 Note: You cannot enable Dev Hub in a Developer Edition org in which you have defined a namespace. You cannot define a namespace in a Developer Edition org that has Dev Hub enabled.

No comments:

Salesforce Flow Tutorial #3 - What is Record Triggered Flow - Post To Chatter

 In this tutorial we will learn how to create and use Record Triggered Flow. The Record triggered flow can be used to fulfill requirements w...