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 / How to set toggle butt...
Power Apps
Unanswered

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 
 
 
 
 
 
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,383 Super User 2025 Season 2 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

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