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 / Checkbox SQL Update
Power Apps
Answered

Checkbox SQL Update

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am trying to update a bit column in a SQL db using a check box, it sits within a gallery and I have the following actions

 

OnCheck -  Patch('[dbo].[Pending]'; ThisItem, {Verified: 1})

OnUncheck -  Patch('[dbo].[Pending]'; ThisItem, {Verified: 0})

OnSelect - Select(Parent)

Default - If(ThisItem.Verified = 1 ,true,false)

 

The data is populated where it should be however I cant select or update the checkbox, its as if the DisplayMode is set to view however it is not - it is set to edit. 

 

Thanks in advance

Checkbox Prop.png
Categories:
  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    Is it possible to have another control in front of the check box (may be a label or an icon used as background for template) ?

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @gabibalaban. No there are no other controls in front of the checkbox. I have used the "bring to front" feature and still cant access the checkbox

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    What is the DisplayMode of the Gallery that the Checkbox is in?

  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Do you mean that your checkbox can not be checked or unchecked?

    Please check:

    1)the checkbox's DisplayMode, set it to :DisplayMode.Edit

    352.PNG

     

    2)the gallery's DisplayMode, set it to :DisplayMode.Edit  //the gallery's mode will affect all the controls inside it.

    353.PNG

     

    What's more, make sure that your sql table has primary key.

    If not, you can not update successfully in powerapps.

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @RandyHayes - the gallery display mode was the issue.

     

    Do you know the latency between checking a checkbox and the db updating ?  are there any other properties that need to be completed to enable an update to the db ?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Glad that helped.

     

    The latency will depend on many factors and is not necessarily a constant.  From device speed to internet network speed to database speed.  Many hurdles to jump to make a change.

     

    If latency is an issue, then consider the design of your app and if it is required to write-back all the time.  If not, you can go to a local collection rather than a datasource (gather data to collection and work with that, then write back to db when needed).

    If it must be real-time, then you will be subject to the mercy of the bits on the wire.

     

    One method I do often for this is a "fire and forget" process.  Essential a hybrid of the above.  I work with a local collection and it is fast (for the user).  When they have a change and it needs to write back, then I do that in a separate process asynchronously.  It is assumed the process will complete and no other interaction is needed.  It a bit tricky to put together, but it is an option.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for the detailed answer @RandyHayes . 

     

    I thought latency might have been an issue however I think the issue is that the field just isn't updating, is there anything wrong in the above OnCheck formula ? or any other properties that need updating.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Yes, I would try this instead for your OnCheck and OnUnCheck:

    OnCheck -  UpdateIf('[dbo].[Pending]'; ID=ThisItem.ID, {Verified: 1})

    OnUncheck -  UpdateIf('[dbo].[Pending]'; ID=ThisItem.ID, {Verified: 0})

    This is assuming there is an ID field in your data source that uniquely identified the record.  If not, substitute with the appropriate identifier field name.

    UpdateIf is much more reliable than Patch.  Especially with Boolean/Bit fields.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    That has worked perfectly, thanks for your help @RandyHayes 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard