EP - 32 | How to use Dynamic Forms In Flow | Lightning Flow Series ⚡

 


How to use Dynamic Forms

So, what are Dynamic forms?
With the help of Dynamic form we can simplify the process of creating and updating records in salesforce.
Dynamic forms for flow is a wonderful option that enables efficient configuration of a wide array of use cases we have for flow.

It helps us getting fields directly from our object with the correct Labels and Validations.

In today's example we will learn both the things.
  • How to create a record using Dynamic Forms
  • How to update a record using Dynamic Forms

Use Case : Create a flow to create a new Case record using dynamic forms and add it to a Lightning app.

Step 1 : Create a Screen Flow.

We will create an screen flow and take a Screen Element on which we will add our form.
On the screen element near Component you will see "fields". Click on it and it will ask you to provide a "Record Variable"


For this we will create a record variable of object Case because we want to insert a record to case object and add it here.


As soon as you will add the variable there, you will see all the fields of Case Object below that :


So now, Just drag and drop the fields that you want in your create Case form and you are good to go.
Guess what?  
You don't have to add any require field, Label or Validations because it's already there.
Isn't that great. 🎉🎉

I have added some fields as you can see here :


When you will click on any field, you will be able to see the details :

I clicked on the Subject field :

Now, let's give our screen a name and click on done to save it.

Step 2 : So, we have create our Dynamic Form but to save data into the Database we will need a create record element.
Let's take a Create Record Element. Now, because we took a Record Variable in the starting step all the data that we fill in the fields will automatically be stored in that record variable.
In your Create Record Element you just need to add that record variable and no need of any additional field mapping.
Have a look :



That's it. You flow with Dynamic Form is done. Add it to a Lightning app and you can start creating your case with this wonderful flow.

Have a look at the flow :


Now, Let's start creating a flow for Updating Case Record :

For updating a case we will add this flow to the Case Details Page so that we could take the recordId from there and we could tell the flow that this is the record we want to update.

Step 1 : Take a Get Record Element to get the case record with the condition ID equals recordId.
Before that create a text variable with name "recordId" in which we will get our CaseID.

Here is the recordId varible :


Here is the Get Record Element :


Step 2 : Repeat the first step from previous example (Create Case) and enter the Get Record Element Name in "Record Variable" option.
Drag and Drop the fields you want to update. I have added the below fields :


Step 3 : Take an Update Record Element and add the Record Variable name there. With that you will be able to update the record without mapping any field individually.


Step 4 : Add a success screen for user to know that record has updated.



Here is how your flow should look :


Step 5 : Add a Action button to Case Object with the Flow details and add it to the case details page using app builder. (To know how to do it, please checkout the video at the end of this article)


When you will click on the button here is how the flow will look :


That's it. Your Flow is working fine.
Do try it out and let me know if you have any questions regarding any of the blogs.

Feel free to connect, comment and ping me on any of the social media platforms. 🙂

To checkout and learn this example through video, Check this 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

0 Comments