Import Data with VS Code

This post isn’t fully baked, but here are some instructions on how to import data with VisualStudio Code! I used this because I was importing data to objects that did not have API yet – new products that were not released to the public yet. This is not a common scenario. But there may be other valuable use cases.

  1. Make an External ID field on your object and check boxes for unique and external id. Let’s call it External ID aka External_ID__c.
    • Give your system administrator access to that field.
  2. Prep your spreadsheet.
    • Each row header needs to be the API name of the field. Absolutely exactly correct or it won’t work. You don’t match fields in this process.
    • Export as CSV.
  1. Create a column for External_ID__c and populate that column with unique values like 1, 2, 3, etc.
  2. Create a VS Salesforce Project. This will save as a bunch of files on your computer.
  3. In your computer’s directory or folder system, find where you saved the project.
    • Create a new folder and call in “File” and save it in the first level under the main folder.
    • Save the CSV you exported to that folder. It can be helpful to change the name of the file to something simple like “mydata”
    • Back in VSCode, you can see the folder and file have magically appeared in your project!
  4. Connect to your Salesforce org:
    • View, Command Palette, SFDX: Authorize an Org. Follow the prompts to connect to the org where you want to import the data.
  5. Copy this command into your terminal and modify it to have the correct object, name of your folder and file, and your external id field’s API name.
sfdx force:data:bulk:upsert -s Account -f file/myData.csv -i External_Id__c
  • After you’re done, you can check the status in your Salesforce org by searching “Bulk Data Load.

Published by


Jessie joined 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!

One thought on “Import Data with VS Code”

Leave a Reply