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)

Please wait while flipbook is loading. For more related info, FAQs and issues please refer to DearFlip WordPress Flipbook Plugin Help documentation.

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
11 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.

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”