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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to set toggle butt...
Power Apps
Suggested Answer

How to set toggle button to true when update

(0) ShareShare
ReportReport
Posted on by 18
Hi all
Can anybody help me, Thanks.
 
I have a toggle button, named check flag. I want to set its value to true whenever I update the record and insert in a Sql database. Right now, if the user switches it to true manually, a value of 1 is inserted in sql ( and 0 otherwise) which is behaving properly. In short, I want to eliminate this step of a user checking the toggle button, and having it set to true automatically on update, eventually hiding the toggle button.
 
 I am having problems to insert the required codes before the SubmitForm (Form1). Thanks to guide me, ( I tried DataCardValue5.Value = true, but it does not work).  Just for info, the PowerApps is integrated with Powerbi, there is no insert 
 
 
 
 
 
Screenshot 2024-12-06 115435.png
Screenshot 2024-12-06 115619.png
Categories:
I have the same question (0)
  • Suggested answer
    NziokiB Profile Picture
    83 on at
    Since you can toggle between 0 and 1, I will focus on how the toggling can be done automatically when someone submits a transaction record or the target transaction field.
     
    I have simulated your Power Apps Fx challenge using a button control on a Canvas App. When you click your “Add New Record” button, create a variable to set the toggle control state to false:
     
    /* Initialize the variable to false when the "Add New Record" button is clicked */
     
    UpdateContext({varTXNRecordUpdated: false});
     
    /* Include your other code for adding the new record. */
     
    /* Update the variable to true after the transaction record is updated: */
     
    UpdateContext({varTXNRecordUpdated: true});
     
    /* Patch the updated record to your SQL database. */
     
    IMPORTANT:
    Set the toggle control's default property to the variable:
     
    varTXNRecordUpdated
  • JC-04111302-0 Profile Picture
    18 on at
    Thank you. Under your correction, I believe it may not be optimum by having a patch for the Toggle button, followed immediately by a  SubmitForm  (OnSelect  control of the update button).
     
    I would like to have the Toggle value set to true just before the SubmitForm and the toggle button gets updated in the database as all the other fields right now.
     
    My problem is that I do not know what codes to insert.
  • Suggested answer
    timl Profile Picture
    36,682 Super User 2026 Season 1 on at
    Hi JC-04111302-0 
     
    The easiest way to do this is to modify the Update property of the 'Check Flag_DataCard1' card in your form.
     
    It'll probably be set to DataCardValue5.Value. If you replace this with true, it'll set the value to true whenever you do an update.
     
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 94

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 38 Super User 2026 Season 1

Last 30 days Overall leaderboard