web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Toggle - using variabl...
Power Apps
Unanswered

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:
I have the same question (0)
  • Verified answer
    StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    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

  • C-Papa Profile Picture
    1,836 on at

    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)

  • JimJim Profile Picture
    289 on at

    @C-Papa , @StalinPonnusamy ,

     

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

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @JimJim

     

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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard