Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Toggle - using variable as default

(0) ShareShare
ReportReport
Posted on by 289

Hi Guys,

 

I have an app with a toggle button which allows the user to hide or display another field, it is not working for me.

This is my setup:

 

Toggle on Check: Set(varAuditVisible, true)

Toggle on UnCheck: Set(varAuditVisible, false)

Audit Field Visibility: varAuditVisible

 

So far so good, switching the toggle will hide / display the audit card.

 

Now what I am trying to do is set the default value of the toggle button (when the form is in View mode then varAuditVisible should always = true and for New mode varAuditVisible should always = false), I have set it as follows:

 

Toggle Default: varAuditVisible

 

This is where things start going downhill. When I set the toggle to true and reload the screen, varAuditVisible flips between true / false repeatedly, it gets stuck in a loop. The same doesn't happen when I set the toggle to false and reload the screen. I can't work out what is going on.

 

On the button to create a  new request I have added:

 

Set(varAuditVisible, false)

Categories:
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at
    Re: Toggle - using variable as default

    Hi @JimJim

     

    It happens sometimes for all of them. Good, you decided to get help.

  • JimJim Profile Picture
    289 on at
    Re: Toggle - using variable as default

    @C-Papa , @StalinPonnusamy ,

     

    Thank you both for taking the time to reply. I was completely over thinking things

  • C-Papa Profile Picture
    1,836 on at
    Re: Toggle - using variable as default

    Hi, you don't need to set a variable as the toggle itself is true or false, therefore, the visible property can simply be toggle1.Value where toggle1 is your toggle name. 

     

    change the default value of the toggle to If(Form1.Mode = FormMode.New,false,true)

  • Verified answer
    StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at
    Re: Toggle - using variable as default

    Hi @JimJim 

     

    Your current method is recursive. So just set the default property of Toggle control to

    FormName.Mode=FormMode.New

     In this case, for form new toggle is yes

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

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,605 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,946 Most Valuable Professional

Leaderboard