Examples of Control validations in PowerApps



Many times we have situations where we need to validate various controls on any form. Doing this on PowerApps forms is tricky (being a techie, your default psyche would be to write one line of code to achieve this -- however as you know, that is not the case with the PowerApps: courtesy its low code, no code philosophy 💔💔💔).

To check if a control is empty:

The following form contains an EmplId field, which is a mandatory field. We can add a label file like this:



Go to the label file's Visible event:


And write on the following formula:

To check if an entered Email Id is correct:



And then in the visible event of the label control, you write:



As a result, when you run the form, as a preview:


Giving something gibberish will give you an error like this. However, giving a proper email Id, this label disappears:


Date control validations:
Similarly, we can embed a datepicker control and ensure that the user doesn't select a future date, simply by writing:







Conditional visibility of controls:

When an employee's age is above 50, then suppose the organization makes him to invest in NPS. The following arrangement can help you with that:

The slider control allows the user to choose any value between 25 to 60. The below label and controls can be made to be given a visible event that says:

Working with signatures (pen input controls):
Pen input controls are an amazing feature of PowerApps, that can help the user to validate and store their signatures. Go ahead with selecting a 'Pen input' control from the 'Insert' drop-down list:

 You can resize the resulting control to occupy the maximum width of the screen form:

Pen controls can be used just not to capture the signature, but also
a. You can reset/remove whatever you have drawn
b. You can change the color of the pen while signing.
c. You can erase the drawing if needed.

Now, go to the signature control, select Advanced >> OnSelect event:


Here I am storing the value of the image in a local variable called: ImageContent >>


Validating the user doesn't submit without signing:
On your submit button >> DisplayMode event, write the following:

It checks the value of the local variable with the input image value.
Consequently, as long as you are not writing any signature, the submit button won't be enabled at all:


Signing on, will enable my submit button:


So much for today. Will come back with more insights and examples of PowerApps with D365FO, soon. 
Stay tuned.👋👋👋

Comments

Popular posts from this blog

X++ : mistakes which developers commit the most

Make your menu items visible on main menu, conditionally,, using this cool feature of D365FO

Speed up your execution performance by using SysGlobalCaches