Use Case: Mark A File Upload as Required in Flow

Have you tried the File Upload component in Screen Flow but got frustrated because we can’t mark it as required? I have! This solution is a workaround to help you mark the File Upload as required (or at least it feels like it) by creating a “fake loop”. This fake loop will only break when there is a file uploaded – cool right? I love creating fake loops so much. I don’t know if this is a good practice, but at least it works great! So let’s dive in!

* Big thanks to Chuck for sending in the case!

Lulu Mobile uses the standard Account object and they want to create an Action called “Upload File”. They also want to ensure that the users upload at least one file before they can finish the flow.

We will create a Screen Flow with the File Upload component. We will also create a fake loop inside the Flow – if no file is there, link back to the upload screen; If there are files, proceed to the finish screen.

To achieve this, we will utilize the Content Document IDs variable that the File Upload component generates automatically. This variable is a collection that stores the files’ 18-digit Ids after the upload. If there is no file, it will return [ ] (empty collection); If it has more than one file, it will return [ (18-digit Id), (18-digit Id)].

Thus, we can use the LEN() formula to count how long the “Content Document IDs” collection is. 2 means it has no file, 20 means it has one file (18 + 2 brackets), 39 means it has 2 files (18 * 2 + 1 comma + 2 brackets).

Flow Chart (deactivate last login date)

Steps (deactivate last login date)

Screen FlowAssignmentFormulaFormula
DecisionVariable

Does the solution solve your problem? If not, write us what your problem is and we will build the flow for you!

Official Salesforce Help Article On Flow

Subscribe
Notify of
guest

18 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Shreya

Thank you!! You saved me:)

Shell

Thanks, Melody! It’s Really useful. There is one question:

After the file is uploaded, there is nothing in the Files Related List. What else should I do to automatically put the file uploaded in the File related list.

Thanks in advance!

Shell

Hi Melody,

Problem fixed, I haven’t entered the “related record id”. Thanks very much.

Laís

Hi, Melody.
I put da variable RecordId in the “Related Record Id” field as you said, but it doesn’t works. Is there something more to do in this Flow?

Vincent

The easiest flow setup I’ve seen!
I’m pumped to see this working in my sandbox.

Harikrishna

Hi Melody,

This is really useful for me, but one catch we could see is that once we came back to the same screen because of not uploading a file, all the remaining element(other input elements on the screen) values were reset. Is there anything we can do to retain the values.

Thank you!

Brian

Hey Melody,

Thank you for this demo, its helped alot for my particular use case. I have question regarding the formula to calculate the file length. I’m trying to add the file upload screen component the LEN but its saying the resource cant be used as a merge field? I’m creating a new resource with type “formula” and data type “number”

Terry

Hi Melody, I was so excited when this worked for me. Then, suddenly, it stopped working. The flow does not catch when a file is not submitted. I made no changes. WIll you take a look?

Cyndie Shaffstall

Hello, Melody!

I have built this flow and it seems to work perfectly (thank you!).

I would like to take it a step further, however, and require a contract upload when a user changes the opportunity stage to closed-won. The last slide in your deck indicates it’s not normal to deploy this as is but rather as a part of another flow so I tried using an auto-trigger flow and choosing this as a subflow but apparently, I cannot mix the two flow types. How can I deploy only when the opportunity is won?

Last edited 1 year ago by Cyndie Shaffstall
T A

This was very helpful to make screen flow fields hidden until a mandatory file was uploaded. Great article!

Vaibhav

Hi,

Need your help on this flow while uploading the file I want to require one field will be mandated, 
a field type will be picklist, and a field name will be document type, so when a user uploads the file then
 on the related list against the file the new field value will appear so can you help me on

Adam

Thank you! This is awesome and works great.

I need people to create multiple records with files uploaded so I added an extra variable to reset the value before it goes into the decision step.