Import Data from CSV Files Using Salesforce Flow

This Post was most recently updated on: 11/29/21

You can now upload CSV data and turn it into Salesforce records with just a couple of Flow elements

This action is based on original work by Narender Singh, plus nice new improvements by Hijlko and Suraj Pillai.

(Interested in exporting records to CSV? Check that out here)

Here’s all that’s needed to take a typical CSV file and turn it into a collection of Accounts that you can save or modify.

The work is done by the ConvertCSVToRecords invocable action. It takes as input one or more Content Document ID’s. This is the main way you refer to files that have been uploaded to Salesforce. In the example above, we use a File Upload screen component to upload a CSV file. (see Considerations: Uploading Files, below for more information). It outputs a Content Document ID which is then fed into the new action.

The action takes advantage of Flow support for generic SObjects in invocable actions. This is the same enhancement that enables Collection Actions. Here, at design time, I specify both the name of the object type “Account” and you select Account as the expect output from the action:

Considerations: Uploading Files

The video in this post shows an example that uses the out-of-the-box File Upload component. It requires a recordId to be provided, and it stores uploaded files ‘on’ that recordId. This makes a lot of sense when you’re trying to upload Account or Contact-related files, but doesn’t make a lot of sense here where we’re just trying to import data. As the video here shows, I actually created a separate object just to hold these values.The import process doesn’t actually make use of this related record. This is all a little annoying. Fortunately, since that video was recorded members of the Flow community have created a replacement extension called File Upload Improved, which doesn’t require a recordId. We recommend that for use with CSV Uploading.

CSV File Considerations

The first row of your file should consist of the field names you want to upload. Make sure you use apinames, include “__c” for your custom fields, and pay attention to the required fields for the records you’re uploading. Note: there should be no NULL values in the last column of CSV.

As of Version 1.2, the following things are supported:

Row Data Support

  • Text and Date fields
  • Embedded commas
  • Rows/File beginning and ending with quotes
  • Newline characters within columns
  • Null columns at the end of a row
  • Supports the CSV spec definition of double quotes, which is represented by consecutive double quotes ("") within a column enclosed in double quotes:

Column Header Support

Column Headers should be in the first row of the file and should be api field names:

Column Headers that are not already field API names will be converted to API Name format

Purchase Amount => Purchase_Amount__c
Nuts & Bolts => Nuts_Bolts__c

Support for Non-US Separators

Contributor Hijlko added this useful improvement. With it, you can import CSV files containing values that use non-comma separators like semicolons. Standard US csv uses a comma as a field separator while most European csv’s use a semicolon as a field seperator.The code can now import muli region CSV files
Numbers/currency like 1,2345.56 (US) and 1.234,56 (EU) are converted to 1234.56

You can now set the following:

  • Field Separator
  • Thousand Separator
  • Decimal Separator
  • Currency Symbol

If these inputs are left empty, the existing default values will be used.

Support for Non-US Dates

Date values in the formats YYYY-MM-DD and DD-MM-YYYY (or with non-hyphen separators like YYYY/MM/DD and DD/MM/YYYY) are now converted by default to YYYY-MM-DD, which is the Salesforce standard. You can set the Date Format input: The default is yyyy-MM-dd or the local date format. Other supported formats are dd-MM-yyyy and MM-dd-yyyy



Object API NameRequired. Tells Flow what to convert your data into. Example “Account”. Make sure your CSV file has all the required fields
contentDocumentIdA single Content Document record ID string

Collection of Strings.
isTrimSet isTrim to true to have any leading or trailing spaces removed.
Date FormatDate format used in the file. Default is yyyy-MM-dd or the local date format. Other supported formats are dd-MM-yyyy and MM-dd-yyyy
Separator 1: FieldsThe character that indicates a separation between two fields. Defaults to a comma. European content often uses a semi-colon
Separator 2: DecimalsThe character that distinguishes between the left side and right side of a value, such as 23.45. Defaults to period.
Separator 3: ThousandsThe character that distinguishes between thousands, such as 230.454. Defaults to comma.
Separator 4: Currency


A collection of Records

Install Package

Version 1.4.1 11/29 – bug fixes

  • Handles negative numbers.
  • Handles ‘1’ and ‘0’ for ‘true’ and ‘false’ respectively for boolean fields.

Old Versions

Version 1.4 Unlocked 11/2/21 Added Date Format input and fixed some bugs

1.3.2 Unlocked 10/2/21

Version 1.3 Unlocked 9/3/21 Support for Non-US Separators,Support for Non-US Dates ,Additional Robustness in Handling Non-Alphabetical Characters

View Source