Have you read about Forms, when to use them & how to use them? If not, let’s have a quick read and build our understanding. By the end of the blog, you will have a demo ready.
Forms are a quick and efficient way of creating, displaying, and modifying your data. It connects to your data source and gives you quick access to easily add required fields. This is a much simpler way in comparison to adding each field and then submitting data individually on a screen.
Let us add two screens. One screen with Gallery to display the list of records & some icons for adding, viewing, and editing data. I took the accounts table from Dataverse. Next screen with the form and button to add data.
There are three types of forms that we could use depending upon the scenario.
This is generally used when we want the user to input a new set of data
How to use it – You can put the following formula on the ‘OnSelect’ property of the icon or button.
Use this form when you want to display the data. Alternatively, this opens the data in read-only mode. Pass the selected item to the screen via a variable & update the Items property with the variable used on the form
Set(varSelected, ThisItem); ViewForm(Form1); Navigate(Screen2,ScreenTransition.CoverRight);
Use this form when you want to modify the existing data. Depending upon the navigation of the screen, you may want to pass the variable name as well so we know user selected which data. Make sure to update the item property of the form with the variable name.
Set(varSelected, ThisItem); EditForm(Form1); Navigate(Screen2,ScreenTransition.CoverRight);
Also, note that I have used single screen & single form for the New, View & Edit form. I have handled it via navigation of what icon/button was clicked.
The default mode of the form was set to ‘New’.
Alternatively, you can also play with the mode of the form & update the OnVisible property of the form.
I have added two different buttons as well for Add & Modify to add new data & modify existing data respectively.
You can control the button visibility via the ‘Visible’ property of the button –
For adding new data / Submit button –
(Form1.Mode <> FormMode.Edit) && (Form1.Mode <> FormMode.View)
For modifying data / Update button –
(Form1.Mode <> FormMode.New) && (Form1.Mode <> FormMode.View)
What’s the benefit –
Forms will help you reduce the number of controls needed on your screen.
Using the same form will also decrease the number of screens needed.
Let us check the beginner way Vs advanced way –
Beginner way leads to a minimum of 4 screens & 3 forms (Home screen, New screen, View screen, Edit Screen)
The advanced way leads to 2 screens and 1 form (Home screen, Form screen)
End user experience will have no impact, the user journey will be same. Its more related to performance of the app.
Read official documentation on Limitation on number of controls in your canvas app.
Read official documentation on forms here
Hope this helps!
Keep reading, keep enjoying, keep exploring!