Skip to main content

Notifications

Community site session details

Community site session details

Session Id : RC2FUFD9Dcezt8teN83G/U
Power Apps - Building Power Apps
Answered

Reset toggle control in component

Like (0) ShareShare
ReportReport
Posted on 14 Aug 2023 19:32:11 by 27

Hello,

 

For the sake of simplicity, my PowerApps component contains a text input control and a toggle control. Two instances of the component are inserted in a screen.

What I would like help with is how to set both toggle controls to false with one button. Otherwise, "false" is the default parameter of the toggle in the component setup, so somehow a reset would be the goal.

 

Thanks,

Zoltan

 

kzoltan_0-1692041215432.png

 

Categories:
  • kzoltan Profile Picture
    27 on 15 Aug 2023 at 07:22:21
    Re: Reset toggle control in component

    Thanks @graeme_findlay  and @hasnainhaider68 

    This was the key:

    "UpdateContext({ResetToggle: true})
    UpdateContext({ResetToggle: false})"

     

    It does not work with a single line.

  • hasnainhaider68 Profile Picture
    47 on 15 Aug 2023 at 07:11:14
    Re: Reset toggle control in component

    Dear,

    you should try this

    1. Create a Reset Button: Add a button control to your PowerApps screen. This button will be used to trigger the reset action for both toggle controls.

    2. Set the Reset Button's OnSelect Property: Select the reset button, and in the formula bar or the "OnSelect" property of the button, add the following formula:

      UpdateContext({ResetToggle: true})
      UpdateContext({ResetToggle: false})
      This code snippet first sets the "ResetToggle" context variable to true, and then immediately sets it back to false. This will trigger a recalculation of the "ResetToggle" variable and cause the toggle controls to reset.

    3. Update the Toggle Controls' Default Properties: For each of the toggle controls in your component, you will need to update the "Default" property to take into account the "ResetToggle" variable. Assuming your toggle control's default property is currently set to false, you can modify it as follows:
      If(ResetToggle, false, YourOriginalDefaultValue)

  • Verified answer
    graeme_findlay Profile Picture
    47 on 15 Aug 2023 at 07:06:34
    Re: Reset toggle control in component

    Ah, ok @kzoltan ,

     

    I think this solution is what you’re looking for in that case

     

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Reset-controls-within-a-component/m-p/1589432#M407501

  • kzoltan Profile Picture
    27 on 15 Aug 2023 at 06:56:42
    Re: Reset toggle control in component

    Thanks for the replies.

    The toggle is part of the component, not a standalone control. I assume that something needs to be set in the custom properties.

     

    kzoltan_0-1692082310544.png

     

  • Devvj Profile Picture
    1,127 Super User 2024 Season 1 on 14 Aug 2023 at 19:49:38
    Re: Reset toggle control in component

    Hi,
    Alt, you can create 2 variables on the button like such (onselect):

    Set(var1, false);
    Set(var2, false);

    and then set the default property on toggle 1 to "var1" and toogle 2 to "var2".

    Devvj_0-1692042511997.png

     

    Devvj_1-1692042538949.png

     

     

     

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

  • graeme_findlay Profile Picture
    47 on 14 Aug 2023 at 19:47:24
    Re: Reset toggle control in component

    @kzoltan 

     

    You can use the reset function for OnSelect of your button

     

    Reset(Toggle1);Reset(Toggle2)

     

    graeme_findlay_0-1692042437852.png

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,679 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard