Notify() and User() function in Powerapps

1. Notify Function in Power Apps

The Notify function displays a banner message to the user at the top of the screen. The notification will remain until the user dismisses it or the timeout expires which defaults to 10 seconds.

An appropriate color and icon are used depending on the type of the message. The type is specified by the second argument to the function:

Note: The character limit for Notify function is 500 characters.

S. No.NotificationType ArgumentDescription
1NotificationType.Error Displays the message as an error.
2NotificationType.Information Displays the message as informational. This is the default value for NotificationType argument.
3 NotificationType.SuccessDisplays the message as success.
4 NotificationType.Warning Displays the message as a warning.

Power Apps Syntax

Notify(Message [, NotificationType [ , Timeout ] ] )

The function has the following parameters:

Example:Step 1: Add a Button control to the screen.

Step 2: Set the OnSelect property of the Button to the following powerapps formula.

Power Apps Formula

Notify("Hello Ashish, Your website is live now")

Step 3: Click or press the button.
Each time the button is clicked, the message “Hello Ashish, Your website is live now” is displayed to the user as informational. It will dismiss automatically in 10 seconds (default timeout) if the user does not dismiss it or press the button again. To dismiss it press the x icon on the top-right of the notification bar.

Notify function in Power Apps

Step 4: Change the type of message to indicate an error. Add a second argument to our formula:

Power Apps Formula

Notify("Hello Ashish, Your website is live now", NotificationType.Error )

Step 5: Click or press the button.
Now each time the button is clicked, the message “Hello Ashish, Your website is live now” is displayed to the user as an error. It will dismiss automatically in 10 seconds (default timeout) if the user does not dismiss it or press the button again. To dismiss it press the x icon on the top-right of the notification bar.

Notify function in Power Apps
Notify function in Power Apps

Step 6: Change the type of message to indicate a warning. Change the second argument in our formula:

Power Apps Formula

Notify("Hello Ashish, Your website is live now", NotificationType.Warning, 4000)
Notify function in Power Apps

Step 7: Click or press the button.
Now each time the button is clicked, the message “Hello Ashish, Your website is live now" is displayed to the user as a warning. It will dismiss automatically in 4 seconds (4,000 milliseconds) if the user does not dismiss it or press the button again. To dismiss it press the x icon on the top-right of the notification bar.

Notify function in Power Apps

Step 8: Change the type of message to indicate success. Change the second argument in our formula:

Power Apps Formula

Notify("Hello, World", NotificationType.Success, 0 )
Notify function in Power Apps

Step 9: Click or press the button.
Now each time the button is clicked, the message “Hello Ashish, Your website is live now" is displayed to the user as success. With a 0 timeout, the notification will only be dismissed by the user or by pressing the button again. To dismiss it press the x icon on the top-right of the notification bar.

Notify function in Power Apps

2. User Function in Power Apps

In Power Apps, we can show information about the current user who is signed into a canvas app with the User() function.

The User() function returns the following information about the current user:

FormulaDescription
User()It returns a record that have three information User Full name, User’s Email and the User picture.
User().FullNameIt returns the User’s FullName as Text.
User().EmailIt returns the User’s Email as Text.
User().ImageIt returns the User’s picture.

Example:Step 1: Add a Text label control and set its Text property to User().Email.
In the following Image we can see that the User() returns a record in which we have three information.

Notify function in Power Apps

We can show the email id in the label control.

Notify function in Power Apps

Step 2: Add one Image control to the screen. And set its Image property to the formula User().Image.
It shows the Image of the current user, if no image is added in the account, then the default image is shown, as in the following image.

Notify function in Power Apps

Step 3: Insert a Text label control and change the Text property to the formula User().FullName. The formula returns the full name of the current user.

Notify function in Power Apps

App Optimization The User() function queries Azure Active Directory for the current user's information. If we use the User() function multiple times, it needs to query the data each time. This creates repetitive calls to the network that slow down our app.

A better approach would be to store that information in a global variable when the app opens, and then reference that variable throughout our app. We could do this by Modifying the OnStart property of the app with the following formula.

Power Apps Formula

Set(varUser, User())

Now if we want to display the full name of our user, we would change the formula on Text property of the Text label control to the following.

Power Apps Formula

varUser.FullName

The above formula gets us the same output as the formula User().FullName, but instead of having to go back to Azure AD on every screen, Power Apps can reference the value stored in the variable.