Business Applications, PowerApps, Uncategorized

Multiple ways to implement the required field validation in PowerApps. Part 2.

The beginning is here: Multiple ways to implement a required field validation in PowerApps. Part 1.

And this is where it’s getting weirder …

3.  I just know you can do it this way. Don’t ask me why. Data source level validation.

Repeat all steps from 2 for the data source changes up to the Then Save Entity. This time I do it for the Description field. Go back to your app. On the Edit form for the Description card on the Advanced tab Unlock to change properties.


For the Required property specify the following:



4.   Custom required validation. App level validation.


For the scenario where you have to mark a field required or not based on the selection of another field we will implement the custom required field validation:

In my case either Mobile or Business Phone field is required.


Let’s use the context variable IsPhoneSpecified to store the flag if one or both phone fields are populated.

I put the script OnVisible of the Screen1 control:

UpdateContext({IsPhoneSpecified:0});UpdateContext(If(IsBlank(mobilePhone.Text),{IsPhoneSpecified: IsPhoneSpecified + 1},{IsPhoneSpecified: IsPhoneSpecified}));UpdateContext(If(IsBlank(businessPhone.Text),{IsPhoneSpecified: IsPhoneSpecified + 1},{IsPhoneSpecified: IsPhoneSpecified }))


For the mobilePhone control Advanced properties OnChange add the following:

UpdateContext(If(IsBlank(mobilePhone.Text),{IsPhoneSpecified: IsPhoneSpecified + 1},{IsPhoneSpecified: IsPhoneSpecified – 1}))


For the businessPhone control Advanced properties OnChange add the following:

UpdateContext(If(IsBlank(businessPhone.Text),{IsPhoneSpecified: IsPhoneSpecified + 1},{IsPhoneSpecified: IsPhoneSpecified – 1}))

Add a new error label to the form:


Set Visibility of the error label to the expression below:


This is how it works:


Looking good! Unfortunately, it doesn’t stop a user from the actual form submission. So the last step to get it fully working will be to trigger the Submit button visibility based on the IsPhoneSpecified flag value:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s