Visual Studio Code: An Adventurous Admin’s Way to Move Metadata to Another Org

A few weeks ago I shared how to use a package to move metadata between unrelated orgs. That solution is perfect for sharing something you built with other people.

See you later, deployment fish!

When you’re moving metadata between orgs that you control (related or not), try Visual Studio Code! Don’t worry about the “Code” part. You don’t have to read it or write it to use VS Code.

VS Code has lots of benefits that I don’t understand yet (somehow you can use it to move profiles and FLS). I will now teach you all I know. 1) How to deploy between two orgs. 2) How to paste in some code to deploy sections in Flows.

Huge thanks to Brian Ricter for teaching me how to do this!

Prerequisites:

  • Install Visual Studio Code. It’s free!
  • Install the Command Line Interface
  • Install the Salesforce Extension Pack

If you haven’t done any of those yet, complete this really helpful trailhead Quick Start.

Steps

  • Open Visual Studio Code.
  • Click on the View > Command Palette > SFDX: Create Project > Standard
  • Enter a name and hit enter.
  • Select somewhere on your computer for the file to live. Click Create Project.
  • Click on No Default Org Set bottom left.
  • Select SFDX:Authorize an Org
  • Choose org type: production or sandbox.
  • Give that org an alias. I’ll call mine RVFB Sandbox because my goal is to deploy from a Sandbox to Production for the Rainier Valley Food Bank.
  • A window will pop up where you can login into that org and click Allow to give CLI access.
  • Back in VSCode, click on the cloud that appears on left.
  • Find the thing you want. I want to send two flows from the sandbox to production so I find each flow under the Flows section and click the download button (cloud with a down arrow) next to each.

  • Click the Explorer – (this looks like two pieces of paper and ) (I can now see that my flows were pulled into the project).
  • Click on the name of your org in the bottom left. Mine is “RVFB Sandbox.”
  • Follow the same steps as before to authorize a new org. This is the destination org – where I am sending my flow – which in my case is a production org so I name it “RVFB Prod.”
  • Go back to Explorer, if you’re not already in it. Right click on “force-app
  • Click “Deploy Source to Org”. Make sure you’re currently in the destination org. I am sending metadata to production so my destination is RVFB Prod.

Look for a message in the bottom right indicating success (below)!

Deploying Flows with Sections

Just a note that I had a “regionContainer Type” error when deploying some of my flows, because I used the new “Sections” feature. Here’s the error:

force-app/main/default/flows/CREATE_FOOD_BANK_VISIT.flow-meta.xml  HouseholdMembersScreen_Section1 (Screen Component) - Because the "HouseholdMembersScreen_Section1" screen field on the "HouseholdMembersScreen" screen is a section, the regionContainerType is required.

I learned from this stack exchange post how to fix it, but I think the instructions could be clearer.

  1. Make sure you’re on Explorer.
  2. Expand force-app/main/default by clicking on it.
  3. Click on the flow you need to edit.
  4. In the window that now shows you the code behind your flow, search for “Section” and note capitalization counts here! Find the line in your code that has the name of your screen _Section1 and paste underneath:
<regionContainerType>SectionWithoutHeader</regionContainerType>

So my code originally looked like:

...
        <fields>
            <name>HouseholdMembersScreen_Section1</name>
                <fieldType>RegionContainer</fieldType>
            
            <fields>
                <name>HouseholdMembersScreen_Section1_Column1</name>
                <fieldType>Region</fieldType>
...

and I changed it to:

...
        <fields>
            <name>HouseholdMembersScreen_Section1</name>
            <regionContainerType>SectionWithoutHeader</regionContainerType>
                <fieldType>RegionContainer</fieldType>
            
            <fields>
                <name>HouseholdMembersScreen_Section1_Column1</name>
                <fieldType>Region</fieldType>
...

I hope that helps!

Also happy to say that in just a few days I’m now feeling really confident in using VSCode for deployment. Today I pulled in a record page which is under Flexipages in VSCode. I deleted a dashboard that was causing errors and deployed it back to the same org. It didn’t fix the problem, but it was cool to try! 🙂

Published by

JessieRymph

Jessie joined Salesforce.org in 2018 to give introductory webinars to nonprofit customers. She now is a Senior Solution Developer supporting nonprofits and education customers at Salesforce. All opinions expressed on this blog are her own or those of the contributors. She's spent 17 years more or less in CRMs and databases, but didn't meet Salesforce until 2011. Jessie co-led the Seattle Salesforce Nonprofit User Group in 2015-2016. She wrote a sh*tty first draft of a novel and hopes to turn it into a screenplay!

3 thoughts on “Visual Studio Code: An Adventurous Admin’s Way to Move Metadata to Another Org”

Leave a Reply