EP - 24 | Upload Files Using File Uploader in Lightning Flow | Lightning Flow Series⚡️

 

Upload Files Using Lightning Flow

In this blog we will learn how we can use File Upload in Flow.

Use Case : A Client wants a Public Web to Case form on community page. So basically a form on which user can upload as many files as they can if they wish to. Those files should be visible to the case details page.

Step 1 : Let's take a screen element to create the form. 

Here is the form which I have created :


In this I have taken some fields Like Name, Status, Case Origin and for file attachment I have added a checkbox which says "Attachment?".

If the user want to upload an attachment they will check this checkbox. Only if the checkbox is check then the fileupload screen will appear otherwise our flow will skip the file upload part.

Why?

Because if they do not have a file to upload then why should they see the file upload screen.

Step 2 : We will add Create Record Element to create a new case record and storing the values from the previous form. After adding values to fields we will create a variable and save the case id in that variable.

Here is the element :


In this we have added values in Origin, Status and SuppliedName. After that we stored the value in caseId variable.

Why we have stored the id in a variable?
Because we will use that id to relate the uploaded file to this case.

Step 3 : We will take a Decision Element to check if user have clicked on the "Attachment?" checkbox.

Here is the element :



Here we have checked if Attachment equals to true. If this is true then we will show the fileupload screen otherwise we will skip the step.

Step 4 : Take a Screen Element to ask the user for file.

Here is the element :


From components search File upload and drag it to the canvas. After that click on the file upload component and on right side you will see these options.


Here you will see on option which is "Related Record ID". In this option add the CaseId Variable which we have created earlier.
With this the file uploaded will be added to the case.

Step 5 : Take a Get Record Element to take the case with the help of caseid variable.


Step 6 : Take a Screen Element and on that show the user success message that "Your case has been registered and your case number is "{!Get_Case.CaseNumber}"

Here is the screen :


This is how your flow will look :


To checkout the tutorial in detail checkout this video link :


If you have any question please leave a comment below.

If you would like to add something to this post please leave a comment below.
Share this blog with your friends if you find it helpful somehow !

Thanks
Let's learn and grow together.
Love and Peace! 🧡

Post a Comment

1 Comments

  1. I created a flow to create a case. But I'm getting an error while uploading a file as a guest user on the lightning page.

    ReplyDelete