Attention Flow Apex Developers: A Chance For Glory 1 :

Requesting: An apex action that converts a CSV file into a collection of records

Looking for everlasting glory? Want to put Salesforce product managers into your debt? The library of invocable actions needs an action that takes an uploaded file Blob (presumably the Content Document created by the File Upload available in Flow) and the name of an object type (like ‘Account’) and outputs a collection of records, using the Spring ’20 support for List<SObject> variables. The action should assume that the first row of the file contains the names of field names on the record.

There are probably some useful tips to be gleaned from:

http://www.forcetree.com/2010/08/read-and-insert-records-from-csv-file.html

Subscribe
Notify of
guest
13 Comments
Inline Feedbacks
View all comments
Nick Sauer

Out of curiosity, has anyone started working on this one?

Adam White

Alex we might send you over some questions. The out of the box upload component assumes an existing record – is it your intention that this process would kick off from an existing record?

Adam White

Question 2: Do you want this to do any actual DML or only output to a record variable?

Clifford

It’s super annoying that a recordId is required. I’ve just got the requirement to build a custom file uploader for one of my customers. I will probably develop a new file uploader for flow, that will place the files into an AWS S3 bucket and returns the URL.

This file uploader will be placed into a solution offer for one of my customers, who needs a custom feedback formular with Attachments… 🙁

Gidi Abramovich

Alex Hi,
For a long time, I’ve been looking for the other way around- An apex action that converts a collection of records into a CSV file 🙂
Then, I would love to send this file as an email attachment.

Narender Singh

I just saw this today!

I was able to create a basic and generic one(with few considerations). I hope I’m not too late. 😅
Here is the link: https://github.com/forcePanda/Flow-Repo/tree/master/Apex%20Actions/CSV%20file%20to%20Collection%20of%20Records%20converter

Alex Hoffman

Hi Narender, This ended up being so useful for us as well, thanks for this. We’re having an issue though, any names we put in the header row are being rejected, even API names. Here’s an example. Any idea? Really appreciate your help here. ——————————————– Error element Convert_CSV_to_Candidate (FlowActionCall). An Apex error occurred: ConvertCSVToRecords.FlowCustomException: Invalid Field Error: Phone. Please double check the API name of the field. Flow Details Flow API Name: Create_Appointments_with_CSV Type: Screen Flow Version: 1 Status: Inactive Org: WorkSTEPS, Inc. () Flow Interview Details Interview Label: Create Appointments with CSV 4/22/2020 5:10 PM Current User: Alex Hoffman… Read more »

Pete

Did you ever figure this one out? I’m running into the same issue now.

[…] records with just a couple of Flow elements, thanks to Narender’s excellent response to the 1st Chance for Glory published a few weeks back. Make sure to check out his blog at […]

[…] on March 31, we put out the first Chance for Glory Narender Singh responded quickly with a great action that takes uploaded CSV data and converts it […]