If you want to import a CSV file, you can use this existing invocable action. It has a good feature set, but there are some limits on the file size that can be imported that stem from backend Salesforce limits. Andy Haas has provide a complementary Flow Screen Component that also allows CSV imports. This version processes files on your local computer, and can work with larger files. This component will automatically navigate to the next screen when the parsing has been completed.
The CFO at a large company has come to you with a request to allow end users to import a CSV file from their merchant companies each month. He doesn’t want to have to call you each month or learn another platform to import these records. He tells you that they partner with many different merchant processor companies and the files will stay the same each month; he wants the process to be as simple as possible for the end users. You ask him for the CSV files to create an object and fields corresponding to the file.
You sit down, open the CSV file the CFO sent to you, and create the object with the appropriate fields. You then open up a new Screenflow, drag the Convert CSV to Records – LWC Version to the screen, and set up the component’s configuration.
After you have set up the component, you test drive it out and see how quick and simple this will be. You schedule a meeting with the CFO and show him the progress; he is amazed at how well this works.
In the above use case, we talked about utilizing the component for a monthly import that the CFO has to do; this can also be used with a one-time import or a multitude of different use cases where the user is importing a file. If a user is not initiating the import, the existing invocable action will be the correct action to use.
Add the Convert CSV to Records – LWC to the screen.
The inputs consist of 4 required inputs and a large list of optional advanced features. The underlying PapaParse library provides advanced features and is documented in the PapaParse documentation.
|Input Name||Default Value||Description|
|API Name||The name of the component.|
|Input Object||This is used to get the field definition.|
|File Import Label||The label for the file input field.|
|Auto Navigate Next||If true, the flow will automatically navigate to the next screen after the component has been initialized.|
|Delimeter||,||The delimiting character. Leave blank to auto-detect from a list of most common delimiters, or any values passed in through delimitersToGuess.|
|New Line||The newline sequence. Leave blank to auto-detect. It must be one of \r, \n, or \r\n.|
|Quote Character||"||The character used to quote fields. The quoting of all fields is not mandatory. Any field which is not quoted will be correctly read.|
|Escape Character||"||The character used to escape the quote character within a field.|
|Transform Header||A function to apply on each header. The function receives the header as its first argument and the index as second.|
|Dynamic Typing||If true, numeric and boolean data will be converted to their type instead of remaining strings.|
|Encoding||UTF-8||The encoding to use when opening local files. If specified, it must be a value supported by the FileReader API.|
|Comments||A string that indicates a comment (for example, # or //). When Papa encounters a line starting with this string, it will skip the line.|
|Fast Mode||Fast mode speeds up parsing significantly for large inputs. However, it only works when the input has no quoted fields. Fast mode will automatically be enabled if no ” characters appear in the input.|
|Transform||A function to apply on each value. The function receives the value as its first argument and the column number or header name when enabled as its second argument. The return value of the function will replace the value it received. The transform function is applied before dynamicTyping.|
|Delimiters to Guess||An array of delimiters to guess from if the delimiter option is not set.|
For further details on the input values, please visit the PapaParse Documentation.
Please note that the following PapaParse inputs will be set within the component and can not be changed. Keep this in mind if any conflicting inputs will error out.
|Header||TRUE||The first row of parsed data will be interpreted as field names.|
|Skip Empty Lines||TRUE||Lines that are completely empty (those which evaluate to an empty string) will be skipped.|
The header columns are compared against the objects fields, and if the header column is a custom field and the header isn’t labeled that way, the component will rename the header and assign the custom field.
Input Object: Account
CSV Headers: Name, Description, Active
The component will convert the above CSV Headers to the following:
Name, Description, Active__c
|Output Name||API Name||Description|
|Parsed Results||outputValue||An sObject of the parsed results.|
|Is Error||isError||Will be marked true if an error has occurred when attempting to parse the CSV file.|
|Error Message||errorMessage||Will output the value of the error that had occurred.|
Implementing this component can be as simple as creating records right after parsing like so:
Or you can be more complex with loops and filters as the output is an SObject allowing manipulation of the imported data.
With Spring ‘23 and the added ability for reactive screens, you can use this component to preview the data uploaded before creating records.