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.
- 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.
- 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.
- Create a column for External_ID__c and populate that column with unique values like 1, 2, 3, etc.
- Create a VS Salesforce Project. This will save as a bunch of files on your computer.
- 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!
- 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.
- 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.
Get well soon =)