Creating scratch Orgs with namespaces

Salesforce DX allows us to create multiple scratch Orgs with namespaces equivalent to the packaging organization. In order to do this, the first prerequisite is to link your Dev Org with namespaces to the Developer Hub Org. This process is also known as registering namespaces.

To register a namespace in your Developer Hub Org  (if you do not have one, signup using https://developer.Salesforce.com/promotions/Orgs/dx-signup), use the Namespace Register tab and click on Link Namespace, as shown in the following screenshot:

Once you click on Link Namespace, a login for the Salesforce instance pops up. This will be the credentials of the Org where you have namespaced and created your managed packages.

On successfully registering a namespace, you will notice a Namespace Registry record, as shown in the following screenshot:

Once we register the namespace, we can create a scratch Org with the namespace by indicating the namespace in the sfdx-project.json file, as follows:

 {
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"namespace": "SearchApp",
"sfdcLoginUrl": "https://login.Salesforce.com",
"sourceApiVersion": "43.0"
}

Once you create a scratch Org using the following command, you will notice that the Org has the SearchApp namespace:

sfdx force:org:create -s -f config/project-scratch-def.json -a scratch_Org

You can verify this by creating a simple class in the environment and you will see that a namespace prefix has been added, as shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.35.122