Teach Me Salesforce

A community approach to learning salesforce.com

Building Salesforce DX Scratch Orgs from Monolithic Metadata

with one comment

Salesforce DX is revolutionizing SDLC for SFDC. Getting all your metadata from a mature org (the proverbial Monolithic metadataset) is a challenge. I am accepting that challenge and documenting the struggle here, for you.

This post will likely grow over time as I refine the process. Or, perhaps like the advice I’ve read to break down your metadata into distinct modular applications, this will break down into multiple posts.

My Salesforce environment is composed of ~35 UE Orgs that have similar metadata, roughly 80% consistency. So I’ll get to do this ~35 times to perfect it.

Our metadata is hopefully average enough that it represents a good cross-section of the typical Salesforce org out there and thus will help others in this project.

Some Metadata Stats:

Custom Objects: 44
Lines of Apex Code: 161,849 characters of Apex Code
Installed Packages: 0 (actually quite a few but left out of the DX metadata)

Step 1: Metadata Retrieval

I use Copado to backup my metadata daily to Github. So I did not have to use one of the metadata retrieval tools (e.g. Salesforce package.xml Builder) to establish my full set of metadata for conversion.

Step 2: Metadata Conversion

This was the first hurdle. I used sfdx force:mdapi:convert on the unedited metadata I retrieved and starting receiving errors. (error message TK)

I attempted to delete the specific referenced files like SvgIcon.cmp but it seemed like every file in the aura/SvgIcon/ and aura/Toast/ folders was going to throw the error so I deleted all the files and left the empty folders. This allowed me to successfully convert my metadata.

However, I made a mistake in the referenced target folder (-d OUTPUTDIR) in sfdx force:mdapi:convert -r . -d ./force-app and instead of going to the force-app/ folder I created as a sibling to config, the force-app folder was created automatically in the same folder as all my metadata.

Step 3. Create the Scratch Org

Nothing fancy here: sfdx force:org:create -d 30 -v 2U-DevHub -f config/project-scratch-def.json -a 2Ufull01 with the following configs:

{
“orgName”: “2U”,
“country”: “US”,
“edition”: “Enterprise”,
“hasSampleData”: “false”,
“features”: [“PersonAccounts”, “Communities”, “CustomApps”, “CustomTabs”, “DebugApex”, “API”,”MultiCurrency”, “AuthorApex”],
“orgPreferences”: {
“enabled”: [“NetworksEnabled”,”S1DesktopEnabled”, “ChatterEnabled”],
“disabled”: [“IsNameSuffixEnabled”]
}
}

Step 4. Pushing the Metadata

This is where I expect things to get really hard, and where I’ll be documenting what had to be done to make it work.

Next Up: Salesforce DX Monoliths: Exploring 2GP (2nd Generation Packaging)

Advertisements

Written by Always Thinkin

January 4, 2018 at 11:43 am

Posted in Uncategorized

One Response

Subscribe to comments with RSS.

  1. Good article.

    salonigu

    January 22, 2018 at 11:19 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: