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

Import a file stored in Salesforce

Import a CSV already attached to a record with File Value, or keep the uploaded file on the record with Save as Content Document.

The events team attaches the booth scanner export to the trade show's Campaign record the evening the show closes. The next morning, a sales coordinator opens the Campaign and imports the leads from that file, without downloading it and uploading it again.

The CSV Parser covers both sides of this. With File Value, it reads a file already stored in Salesforce: the upload input disappears and the component only maps the columns. With Save as Content Document, it keeps a file the user uploads attached to the record, so the source of an import is always one click away.

A CSV Parser on a flow screen without an upload control, showing Found 5 rows and seven CSV headers each mapped to a Lead field.
A file already in Salesforce, mapped without an upload.

Before you start

  • A screen flow that imports rows with the CSV Parser. Import a CSV file in a screen flow builds one.

  • A Campaign with a CSV file in its Files related list, for part 1. Any object with Files works the same way.

  • A way to launch the flow from the record, so it receives the record's Id: a screen flow action on the Campaign page layout, or the Flow component on the Campaign's Lightning record page.

Part 1: import a file already attached to the record

1

Receive the record Id

Create a text variable named recordId and check Available for input. When the flow runs from a Campaign, this variable holds the Campaign's Id.

2

Find the file with Get Records

Before the screen, add a Get Records element named Get_Booth_Scan_File:

  • Object: Content Version.

  • Conditions: First Publish Location ID equals {!recordId}, File Extension equals csv, Is Latest equals {!$GlobalConstant.True}.

  • Sort by Created Date, descending, and keep only the first record.

This returns the most recent CSV uploaded on that Campaign. Its Content Document ID is the value the CSV Parser needs.

First Publish Location ID is the record a file was first uploaded to. For a file shared to the record later, query Content Document Link with Linked Entity ID equals {!recordId} and use its Content Document ID instead. That object cannot be filtered on the file type, so use it when the record holds only the one file.

3

Point the CSV Parser at the file

Select the CSV Parser on the screen. In the right-hand panel:

  • File Value: {!Get_Booth_Scan_File.ContentDocumentId}. Pick it from the resource list: the panel shows it as a pill labelled Content Document ID.

  • Object Name, Required Fields To Map and Default Mappings: as for an upload. The file is mapped with the same rules.

The CSV Parser settings panel in Flow Builder with Object Name set to Lead and File Value set to the Content Document ID of the Get Records result.
File Value takes the Id of the file found by Get Records.

File Value accepts three kinds of value:

Value
Example

The Id of a file (Content Document or Content Version)

{!Get_Booth_Scan_File.ContentDocumentId}

The CSV content itself, as text

A text variable or text template holding the rows

The CSV content encoded in Base64

The output of an action that returns a file body

4

Decide how much the user sees

With File Value set, the upload input is hidden and the screen opens on the mapping, with sample data under each header. The user can still change a mapping before going on.

  • Leave Hide Mapping off when the files vary, so the user can check the columns.

  • Turn on Hide Mapping when every file has the same headers and your default mappings cover them. The screen then shows only the row count (and the preview, if Show Preview is on). Pre-map CSV columns for a recurring import explains what is still checked with the mapping hidden.

  • Turn on Show Row Count either way.

5

Save and test

Add a Create Records on the CSV Parser's Records after the screen, or a review screen first. Activate the flow, add it to the Campaign page, and open a Campaign with a CSV in its Files.

The screen opens without any upload input. The mapping lists the file's headers with three sample values each, and the row count of the file shows when Show Row Count is on.

Part 2: keep the uploaded file on the record

When the user uploads the file in the flow, the file itself is usually gone once the import is done. Save as Content Document stores it in Salesforce and can attach it to the Campaign, so anyone checking the import later finds the exact file it came from.

1

Turn on Save as Content Document

Select the CSV Parser and click Open Component Builder at the top of the right-hand panel. In the Edit CSV Parser Component window, expand the Save As Content Document group of the Properties tab. This group is not in the right-hand panel.

  • Save as Content Document: on.

  • Content Document Linked Entity Id: {!recordId} (shown as a Record Id pill once picked). The file appears in the Campaign's Files related list. Leave it empty and the file is saved in the uploader's own files, attached to no record.

Click Done to close the window.

The Save As Content Document group of the CSV Parser Component Builder, with Save as Content Document turned on and Content Document Linked Entity Id set to the recordId variable.
The uploaded file is saved and attached to the record.
2

Know when the file is saved

The CSV Parser saves the file the moment the user picks it, before the rows are mapped and before Next:

  • A "Your content document has been created." toast confirms it.

  • The file stays even if the mapping fails or the user leaves the flow.

  • Each upload creates a new file. A user who picks the wrong file and then the right one leaves two files on the record.

File Value and Save as Content Document do not combine: only a file the user uploads is saved.

3

Use the Content Document Id output

Once the file is saved, the CSV Parser's Content Document Id output holds the new file's Id. Use it after the screen, for example to write it to a field on an import log record, or to link the same file to a second record with a Create Records on Content Document Link.

4

Save and test

Run the flow from a Campaign and upload a CSV. The success toast appears as soon as the file is picked. Open the Campaign: the file is in its Files related list, whether or not you finished the flow.

Troubleshooting

"Could not parse the file value provided."

The CSV Parser could not turn File Value into CSV content. Check, in this order:

  • The Get Records found nothing, so File Value is empty or wrong. Debug the flow and look at Get_Booth_Scan_File.

  • The running user cannot see the file. The file is read with the user's own access, so a file on a record they cannot open is treated as missing.

  • The content has no comma at all. The CSV Parser recognizes CSV text by its commas, so a file separated only by semicolons is rejected here. See Fix encoding and delimiter issues.

Accented characters look wrong in a stored file

A file read through File Value is always decoded as UTF-8, whatever Encoding says. Save the file as CSV UTF-8 before attaching it. Fix encoding and delimiter issues explains how to recognize the problem.

The flow imported the wrong file

The record holds several CSV files and the Get Records returned another one. Keep the sort on Created Date descending with only the first record, or add a condition on Title.

An error toast appears on upload with Save as Content Document on

The running user lacks a permission. "You do not have permission to upload files." means they cannot create files. "You do not have permission to link files." or "You do not have permission to link this file." means they cannot attach the file to the record in Content Document Linked Entity Id.

The Content Document Id output is empty

Save as Content Document is off, the save failed (look for an error toast), or the rows came from File Value, which saves nothing.

Was this helpful?