Skip to main content
Community site session details

Community site session details

Session Id : u5PJceJPGUtCDMG3XtqRj8
Power Apps - Building Power Apps
Answered

Toggle switch with another button OnSelect (on save) (SharePoint list)

Like (0) ShareShare
ReportReport
Posted on 26 Apr 2019 19:13:14 by 285

How can I toggle a switch (or tick a checkbox) with another button?

 

I need a hidden Toggle (Yes/No), by default it's OFF. I want another button, that will toggle the switch to ON and then submits the form.

 

How can I achieve this?

 

Many thanks

Categories:
  • ITDeveloper Profile Picture
    2 on 15 Mar 2024 at 23:26:07
    Re: Toggle switch with another button OnSelect (on save) (SharePoint list)

    What if I already have another function for the default property of the toggle?
    What should I do to click on a hidden toggle from an icon?
    I mean I have this code on that property:

    If(
     !IsEmpty(
     CheckInData
     ) && !(lbl_Home_Location.Text = "You aren't at work!"),
     true,
     false
    )

     

  • daniel_w Profile Picture
    15 on 20 Sep 2021 at 07:16:43
    Re: Toggle switch with another button OnSelect (on save) (SharePoint list)

    Hi Randy,

     

    This was very useful information about references to off-screen controls.

     

    I was using the OnCheck property of a toggle on Screen1 to drive some behaviour. The Default property of the toggle Or'd together the outputs of two components, one on Screen1 and the other on Screen2.

     

    In PowerApps Studio, activating the component on Screen2 would trigger the OnCheck behaviour as expected. However doing the same when launching the App from its weblink, or embedding in Teams would not trigger the toggle's OnCheck behaviour.

     

    Per your suggestion, adding a label to Screen2 which referenced the toggle on Screen1 resolved the issue.

     

    Do you have a link to any documentation which describes how PowerApp handles offscreen controls? I haven't been able to find any myself.

     

    Thanks,

     

    Dan.

  • Community Power Platform Member Profile Picture
    on 23 Oct 2019 at 09:54:08
    Re: Toggle switch with another button OnSelect (on save) (SharePoint list)

    Thanks this is very helpful

  • GrischkePro Profile Picture
    285 on 26 Apr 2019 at 19:45:12
    Re: Toggle switch with another button OnSelect (on save) (SharePoint list)

    @RandyHayes 

     

    This is brilliant! I was almost there, just didn't know where to apply the variable 🙂

     

    FYI, I needed to toggle it "on save" without the user knowing about it, so that Flow knows what to do next 😉

     

    Thank you very much! Smiley Very Happy

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 26 Apr 2019 at 19:32:39
    Re: Toggle switch with another button OnSelect (on save) (SharePoint list)

    @GrischkePro 

    One quick way to do this is the use of a variable.

    In your Button OnSelect action use a formula such as this:

       Set(setToggle, true)

     

    Then on your Default property of the Toggle control, set this formula:

       setToggle

     

    If you are using the toggle to then perform an action in the "OnCheck" action of the control, then do your formula, and then at the end, place a Set(setToggle, false) to reset the toggle back so that it can be "called" again.

     

    This is a very useful pattern to do with toggle controls.  HOWEVER, there is one word of warning...

    If you put your toggle control on another screen, you need to at least reference the Toggle Control on the screen where your button is.  You can do that simply enough with a non-visible label with the text property set to yourToggleName.Value

    This will work perfectly from any screen (as long as you have a referencing "dummy label").

     

    I hope this is helpful for you.

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete