While designing applications in the Power App, we may have to interact in real-time with the users to provide proactive feedback so that they can course-correct some data entry mistakes they have done or provide some general information to the users who are filling out a form.
Power Apps provides the Notify function which will display a banner message at the top of the screen. Once the banner message is shown, it will remain displayed until one of the below happens:
- User closes the banner
- A new notification replaces the existing banner
- By default the time out is 10 seconds which is configurable and based on the mentioned time out, the banner auto closes.
The character limit of the notifications is currently set to 500 characters. While displaying the message, we can select one of the 4 categories of the message type, based on which the color and icon of the message will change.
Categories of Messages
We have 4 different types of messages that we can show in the Power App as Notification.
This type is used to show success messages with a green background.
It is used to display general information to the end-user with a grey background.
This notification type is used to show a warning message to the user with a Yellow background
It is used to display an error message with a red background
The syntax of the Notify function is as:
|Notify(Notification Message, NotificationType , Timeout )|
- Notification Message : The message to be shown in the banner
- NotificationType : The type of message to display in the banner. It is optional, default is NotificationType.Information.
- Timeout:The amount of time , the banner should show on the top. Default is 10 seconds. This too is an optional parameter.
Let’s take a scenario where we are creating a registration form for a forum that accepts the User Name, Age, Country of the user submitting the registration. We are also mandating that the user should accept the Terms and Conditions to complete the registration.
While filling the user name, in the On Change property of the text box, we will add a notify function to inform the user that the mentioned user name will be used in the forums using the below expression. We have set the time out to 20 seconds in this case. Setting it to 0 would keep the banner for an unlimited time unless the user closes it or is replaced by another banner.
|Notify(“The selected User Name will be shown in the forum conversations”,NotificationType.Information,20)|
While filling the age text input, In the On Change property, we will check the value of the entered value and show a warning message if the user is below the legal age using the below expression. Here we have not specified the time out and hence it takes the default time out of 10 seconds.
|If(Int(TextInput_Age.Text) <18,Notify(“You need to be above 18 years of age to join the forum”,NotificationType.Warning))|
The checkbox that gets the user consent on the Terms and Conditions by default is checked as it’s mandatory for registration. In case the user unchecks it, we will check for its value in the On Unchecked Property and display an error message with the below expression
|Notify(“To proceed with the registration, you will have to agree to the Fair Usage Policy”,NotificationType.Error);|
Finally, once the user registration details have been patched to the back end, we can show a success message on the On Select of the Registration button
|Notify(“The User Name has been registered. Welcome to the Forum !”,NotificationType.Success)|
Thus, we saw how to use the Notify function in Power Apps to show notification messages of 4 different categories which will show the message as a banner at the top of the app as a way to communicate with the end-users.