Custom error messages for data cards in PowerApps

In a modern form component in PowerApps you get the ability to work with error messages for each field. Here is a step by step guide how you can work with this error messages for each form data card.


Create your own error message for a data card in your form

1. Each data card in a modern form component has its own ErrorMessage field. Before you can work with it, you must activate the advanced settings to change the properties.


2. Select your ErrorMessage field and select the "text" property in which you enter your validation. For example, you can check if the date field must be after today.
        Coalesce(Parent.Error, If(DateValue1.SelectedDate > Today(),
        Blank(), "Date must be greater than today"))

The Coalesce functions will return the first value that isn't blank or an empty string. In this case the first error message. You can add more validations to coalesce function like:

        Coalesce(Parent.Error,If(DateValue1.SelectedDate = Today(), 
        "It's Today", Blank()) ,If(DateValue1.SelectedDate > Today(),
        Blank(), "Date must be greater than today"),
        If(DateValue1.SelectedDate < DateAdd(Today(),90, TimeUnit.Days),
        Blank(), "Date range cannot exceed 90 days"))
3. Make the error message field visible if there is an error text. In the "visible" property enter this function.


You have now a custom error message and create a Custom states and validation from error messages in PowerApps