Latest Posts

PowerApps Button Click Events


PowerApps button is one of the most important OOB components. In this article, we are going to go through some examples related to PowerApps button click event.

PowerApps set TextBox value on button click

The easiest 2 steps process to set a textbox value is

  1. Set Textbox default value to a variable (here variable name is - tempValue)
  2. Set the variable value using button OnSelect property. Two functions are added here.
    • Here, we are assigning current date time to variable – tempValue
    • After that, we are resetting the textbox value using Reset() function.

Close PowerApps on button click

You can use Exit() function on button OnSelect Event.

PowerApps Exit() vs Exit(true)

  • Exit() - Exits the current app and leaves the user signed in. The user is returned to the list of apps.
  • Exit(true) - Exits the current app and the user is signed out. The user will need to sign back in with their credentials before running an app.

PowerApps button click go to another screen

You can use Navigate(targetScreen, transitiontype) function on button OnSelect Event.

  1. Here, the first parameter is the name of the target screen where we want to navigate.
  2. Second parameter is optional, and it specifies what animation will it perform while going from one screen to another.

PowerApps change button text once clicked

Requirement: When the screen loads, the button text should display Save. When the button is clicked, it should display the text as Clicked.

Perform below mentioned three actions.

  1. Button OnSelect property:
    UpdateContext({buttonText:"Clicked"})
    Explanation: Here, we are setting a context variable and in variable we are directly setting text(Clicked) of the button. Reason? We’ll see in the next point.
  2. Button Text property: buttonText.Explanation: We are directly setting the text property of the button to the variable which we set in the earlier step.
  3. Screen OnVisible property:
    UpdateContext({buttonText:"Save"})

Explanation: When we arrive at the screen, the default text value of the button should always be Save.

PowerApps disable button once clicked

Requirement: When the screen loads, the button display mode should be enabled. When the button is clicked, the button should be disabled.

Perform below mentioned three actions.

  1. Button OnSelect property:
    UpdateContext({ButtonDisplay:DisplayMode.Disabled})
    Explanation: Here, we are setting a context variable and in variable we are directly setting display mode of the button. Reason? We’ll see in the next point.
  2. Button Text property: ButtonDisplay.Explanation: We are directly setting the DisplayMode property of the button to the variable which we set in the earlier step.
  3. Screen OnVisible property:
    UpdateContext({ButtonDisplay:DisplayMode.Edit});

Explanation: When we arrive at the screen, the default display mode value of the button should always be Enabled (Edit).

PowerApps navigate to a URL once button is clicked

You can use Launch(TargetPath) function on button OnSelect Event.

Here, there is only one parameter and in which, you need to specify the target URL. When you click on the link, it will open the webpage or app associated with that URL.

PowerApps Start Timer on Button Click

Requirement: When the button on the PowerApps screen is pressed, it should start a timer placed in the application.

Perform below mentioned three actions.

  1. Timer Object: Auto start should be Off
    Explanation: Here, we are setting Auto start property to off because otherwise the timer will start when the screen is loaded which is not what we want here.
  2. Button OnSelectproperty: On button click event we are going to set a variable using below formula.
    UpdateContext({startbutton:true});
  3. Timer Object Start Property: startbutton

Explanation: If the variable (startbutton) value is true (which we set on button click) then it will start the timer, otherwise it will remain false.


We value your Feedback:

Page URL:

Name:

Email:


Suggestion:

© 2024 Code SharePoint