So I am back with another blog on Power Apps and today I am going to discuss with you a very simple requirement. How do I set focus on first field inside a canvas app create or edit form?
This is one of the most common requirements I come across and why not? After all these are the experiences that ease the user to fill out forms when there are large number of fields on the form. Once the first field is highlighted, the user can enter a value and tab out to the next field. So let’s see how we can achieve this.
Power Apps have a function called SetFocus. Let’s see how we can use this function to achieve our requirement.
I have the used the form control to edit and create records. And OnVisible of the screen, I have used the below formula.
However when I run this, the focus is not set set on either the Create or Edit form. And here in come the first limitation. The SetFocus function does not work on the EditForm control. While it is unfortunate, this is how it works for now.
So what is the other way around. To use the SetFocus function, we can just use a scrollable screen with the input controls and then use the Patch function to create and update records. On the OnVisible property of the screen, I use the same formula to set focus on the first control of the screen.
And below is the behavior
Few things to note before I end this blog. The SetFocus function work with the below controls only.
- Button
- Icon
- Image
- TextInput
- Label
You may also like the below posts
Hope this helped!
Debajit Dutta
Business Solutions MVP
Discover more from Debajit's Power Apps & Dynamics 365 Blog
Subscribe to get the latest posts sent to your email.