Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Import a CSV file in a screen flow

Build a screen flow that turns a CSV of trade show booth scans into Leads, with the file checked and mapped on screen before one Create Records saves it.

Your events team comes back from a trade show with a spreadsheet of booth scans and wants them in Salesforce as Leads today. With the CSV Parser on a flow screen, the user drops the file, checks which column goes to which Lead field, and presses Next. One Create Records element saves the rows.

A flow screen after a CSV upload: the upload control, the text Found 5 rows, a Mapping section where seven CSV headers with sample values point to First Name, Last Name, Company, Title, Email, Phone and Description, and an Import leads button.
Five booth leads read from the file, every column matched to a Lead field.

Before you start

  • Avonni Flow Components is installed in your org, and you can create flows and Leads.

  • You have a CSV file to test with. Copy the sample below into a text editor and save it as booth-leads.csv, in UTF-8.

  • Run your first tests in a sandbox, or plan to delete the test Leads afterwards: the last step creates real records.

Steps

1

Create a screen flow and its first screen

  1. In Setup, open Flows and create a new Screen Flow.

  2. Add a Screen element right after Start. Label it Upload Leads.

2

Add the CSV Parser to the screen

  1. In the screen's component list, search for CSV Parser and drag Avonni CSV Parser onto the screen.

  2. Give it an API Name you will recognize later, for example leadCsv. You will pick its output by this name in a later step.

The screen canvas shows "No preview is available for this component." That is expected. Click the component: its main settings load in the panel on the right, which can take several seconds the first time. Everything this tutorial needs is in that panel. The Open Component Builder button at its top opens the full settings, including the Parser and Save As Content Document groups, next to a live preview.

3

Point the parser at the Lead object

  1. Object Name: select Lead. The default is Account.

  2. Label: replace the default Upload Accounts CSV with something your users understand, such as Upload the booth leads (CSV).

Object Name does two jobs. It sets the fields offered in the mapping, and it makes the Records output a collection of Leads, which is what Create Records expects later.

4

Decide what the file must contain

  1. Turn on Required. Without a file, Next stops with "Required CSV file missing."

  2. In Required Fields To Map, select Last Name and Company. A Lead cannot be saved without them, so the screen checks for them before anything else runs.

  3. Turn on Show Row Count. After the upload, the user reads "Found 5 rows." under the drop zone and knows the file was read.

  4. Leave Hide Mapping off. It is off by default, and it keeps the mapping section visible so the user can check and fix each column.

The CSV Parser settings in the Flow Builder screen editor: Open Component Builder button, Label, Object Name set to Lead, Required on, Required Fields To Map with Last Name and Company, Show Row Count on.
The CSV Parser settings in the screen editor's right panel.
5

Keep the standard Next button

The flow's own footer moves the user to the next element. You do not need an extra button on the screen. If you want a clearer word than Next, rename it in the screen's footer settings, for example Import leads.

When the user presses Next, the CSV Parser runs its checks: a missing file or an unmapped required field keeps the user on the screen with a message.

6

Save the rows with Create Records

  1. After the screen, add a Create Records element. Label it Create Leads.

  2. Choose to create multiple records from a collection.

  3. Open the collection picker and type the API name of your parser, leadCsv. Select it, then select Records. The reference reads {!leadCsv.records}.

Records holds one Lead per row of the file, with each value in the field its column was mapped to. The parser also exposes Records Serialized (the same rows as JSON text) and Content Document Id (used when the file is saved in Salesforce). For this flow you only need Records.

7

Save and test

  1. Save the flow, then click Debug or Run.

  2. Upload booth-leads.csv. The mapping section lists the seven headers, each with its first three values under it.

  3. Company, Email and Phone are already matched, because their headers are spelled exactly like the field API names. The other four show an empty picker.

  4. Pick a field for each empty one: First Name, Last Name, Title (for Job title) and Description (for Booth notes).

  5. Check that "Found 5 rows." is shown, then press Next.

A flow screen after a CSV upload: Found 5 rows, and a Mapping section where Company, Email and Phone are matched and First Name, Last Name, Job title and Booth notes have an empty field picker.
Headers spelled like a field API name match on their own, the others wait for a pick.

Open the Leads tab: the five booth leads are there, with the booth notes in Description. If the same export comes back every month, set those four matches once in the flow so the user never has to pick them: see Pre-map CSV columns for a recurring import.

Troubleshooting

Next shows "Required Headers Not Found: LastName. Please add them and try again."

A field listed in Required Fields To Map has no column mapped to it. Usually the file names the column differently (for example Surname) and the user did not pick a field for it. After this message the mapping section is no longer shown, so the user fixes the file and uploads it again. To prevent it, add a Default Mappings entry for each spelling your files use. Pre-map CSV columns for a recurring import shows how.

A column shows an empty picker although the field exists

The header is not spelled exactly like the field's API name (email is not Email). The user can pick the field in the picker, or you can map that header once in Default Mappings. Pre-map CSV columns for a recurring import lists the matching rules.

The field I want is not offered in a column's picker

The picker only offers fields whose type fits the column's first value. A column of email addresses is not offered number, date or checkbox fields, for example. A field already used by another column is shown but cannot be selected: clear it from the other column first.

Accented characters look wrong after the upload

The file was not saved in UTF-8, which is what the parser reads by default. Fix encoding and delimiter issues shows how to tell which encoding the file uses and where to set it.

"The uploaded CSV file exceeded the rows limit. Only the first 10000 rows were processed."

The file has more rows than the parser reads in one go. See Fix encoding and delimiter issues for the limit and what to do.

"Could not retrieve "Lead" object fields. Please verify the object name."

The parser could not load the fields of the object set in Object Name. Check that the object is the right one and that the user running the flow can access it.

Last updated

Was this helpful?