top of page

Flow Apex Action: Create ContentVersion/Files

Aug 25, 2020
1 min read

Hi! 🙂 We cannot create Files(ContentVersion) using the Create Records element in Flows. And the reason is flow doesn’t support Blob data type in flow variables.

Are you wondering why do we need this since we can simply upload files using the standard FileUpload component? Well, what if wanted to create a Note? It can be also useful where you’re receiving blob/base64 data for images through APIs.

So, how does it work?

It’s quite simple. The action takes some inputs and returns the ContentDocument ID of the inserted file.

Parameter

Use for Input

Use for Output

Description

File Data

✔


String input that’ll be stored as VersionData. For images, the string input should be base64 encoded string.

File Extenstion

✔


Type of the file. For notes, it should be ‘SNOTE’.

File Title

✔


Title of the file.

Related Record Id

✔


ID of the record where the file should be added.

ContentDocument ID


✔

ContentDocument ID of the created file(ContentVersion).

You can find the link for the unmanaged package and source code here: https://github.com/forcePanda/Flow-Repo/tree/master/Apex%20Actions/CreateContentVersion(Files)

Demo

Hope you found this one useful! Catch you in the next one! ✌ Thank you for being an awesome reader! Subscribe to this blog for receiving all the latest updates straight to your inbox.

 
 
 

Comments


bottom of page