cancel
Showing results for 
Search instead for 
Did you mean: 
JR-BejeweledOne

'Required' Fields in Power Apps

Do you have fields that need to be required?  Unfortunately, Power Apps does not currently provide the ability to set a control as required and set rules around it.   All hope is not lost, however, look no further……

 

We can implement a clever workaround using star icons and the DisplayMode and Visible properties.

 

The first step in this process is to determine which conditions are needed for the field to be required.   Is it always required or are there a set of conditions, such as values in other fields, that make it required?   Write them down so you don’t miss any.

Add a star icon for each field that is required and position it to the left or right of the required field.

 

  • Height: 10
  • Width: 10
  • Color: Red

           reqfields.jpg

 

In the ‘Visible’ property of the icon set your conditions.    Simple conditions that return a Boolean (true/false) value can be added without using an If statement.  

Example:  IsBlank(SomeField) or IsBlank(SomeField) && SomeField.Selected = “Value”

Conditions that do not return a true/false value need to be wrapped in an If statement.

Example: If(

                   CountRows(

                     Filter(DataSource, SomeColumn = “SomeValue”) ) =0,

                     true,

                    false

                  )

 

Now you can use the Visible property of your star icons to control what the user can do next.   By using the DisplayMode and Visible properties of your controls you can prevent them from being selected until the user has filled out the required field(s).   Using the DisplayMode property allows the control to remain visible but keeps it from being used, while the Visible property hides the control completely.

 

DisplayMode Example:   If(

                         StarIcon.Visible,

                         DisplayMode.Disabled,

                         DisplayMode.Edit

                        )

 

Visible Example:       !StarIcon1.Visible Or

                                    !StarIcon2.Visible Or

                                    !StarIcon3.Visible

 

      reqfields1.jpgreqfields2.jpg

 

These basic principles can be used to control the visibility to see and interact with other controls as well, such as warning labels etc.

Comments