VS Code Setup with ForceCode

VS CodeVS Code is the new direction that Salesforce is going for it’s code editor of choice.  The focus is on DX and Scratch Orgs.

This is how I installed it and set it up to use ForceCode.

ForceCode is an extension that allows you to make a connection to your Salesforce instance.  Sandboxes of course.  It also has some nice tools for working with your code like running tests and displaying test results and code coverage.  Salesforce also has it’s own extensions for working in the Salesforce DX environment.  I added those as well but needed the ability to work directly with Sandboxes which the Salesforce extensions don’t have, yet.

First go to the VS Code site and download the app.

Screen Shot 2018-06-17 at 3.59.13 AM

Run through the basic install process and start the app.

Once the app is open we will need to get the extension.  Look for the Extensions icon on the left menu of the app.  It looks like a square surrounding a square. Screen Shot 2018-06-17 at 4.03.55 AM

Then search for ForceCode and click on the Install button.  You will need to click the Reload button once it is done installing.

Screen Shot 2018-06-17 at 4.14.55 AM

So far everything is going according to plan.  Lets connect it to a Salesforce instance.
First we need to open a folder where we want the files reside.  From the top menu, click on File > Open and either select a folder you want to use or create a new one.

Now for the connection.  There are a couple of ways to do this.  Here is the easiest:

  • From the top menu, click View > Command Palette…
  • Search for forcecode and select the ForceCode Menu option
  • We are prompted for SFDC username
    Screen Shot 2018-06-17 at 4.35.59 AM
  • Then password and token
    Screen Shot 2018-06-17 at 4.41.47 AM
    You may need to request a new token if you don’t have it saved somewhere.  You can do this in your Personal Settings > Reset My Security Token
  • Then we get to choose between Production /Developer or Sandbox / Test.
    Screen Shot 2018-06-17 at 4.46.02 AM
  • Bingo! We should see a message in the bottom of the editor as it tries to connect and then a success message.
    Screen Shot 2018-06-17 at 4.53.04 AM

Now lets get some files from the server.

There are a couple of ways to get files from the server with ForceCode.

  • Open Salesforce File
    This allows you to get singular files
  • Retrieve Package/Matadata
    This allows you to get designated files in a managed package file or to get all the files from the org.

I went with the package.xml option.  I just created a quick package.xml file in the root of the src directory.

<?xml version=”1.0″ encoding=”UTF-8″?>

Go back to the ForceCode Menu and select Retrieve Package/Metadata > Retrieve by package.xml.  Just like that you should see the files located in the src directory.

Hope this was helpful.  Please send your comments below if I missed anything or if there is something particular you are looking for.

More to come on VS Code…

The Ongoing Journey

I’ve been programing for a long time.  Primarily front end web development with a healthy dose of mid-tier data work.

Almost four years ago I was introduced to Salesforce.  I was asked to bring some of my web applications into the Salesforce instance we were migrating to.  Little did I know how that would change the direction of my career.

I started out as a Developer, moved into Admin, and now I’m back to Developing with an Admin perspective.

This is going to be a place for me to catalog some of the best practice options I find.  I hope they are useful to others as well.

Thanks for joining the journey!