cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
kevinsray
Level: Powered On

Patch Checkbox value as OK when checked

I have a screen where there is about 20 checkboxes. A checklist of sorts.

There is also a save button which will be used to patch to a SQL table.

If a checkbox is checked, I would like the result "OK" to be patched to the db for that checkbox and "NO" for the ones which are not checked.

What would be the best way to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
kevinsray
Level: Powered On

Re: Patch Checkbox value as OK when checked

Thank you all for your input.
I have been able to achieve what I was after.


I set each of the checkbox reset value to ResetCheckbox

 

Then put this in the OnSelect
UpdateContext({ResetCheckbox:true});
UpdateContext({ResetCheckbox:false});

 

This worked a treat.
Thank you all for your input.

View solution in original post

3 REPLIES 3
SergioGiusti
Level: Powered On

Re: Patch Checkbox value as OK when checked

in you patch command, put an if statement into the value of the column.

i.e.

patch(my data source,default(my data source),{

   Title:my title value.text

   My1stCheckboxValue:if(checkbox1=true,"OK","NO")

   My2ndCheckboxValue:if(checkbox2=true,"OK","NO")

})

 

etc.

Community Support Team
Community Support Team

Re: Patch Checkbox value as OK when checked

Hi @kevinsray,

Could you please share a screenshot about your app's configuration?

Do you add these Checkboxes within a Gallery or just within a screen?

Further, do you want to add a new record into your SQL table when you click the "Save" button? Or Update corresponding column value of an existing record for that Checkbox?

If you just want to add a new record into your SQL table when you click the "Save" button, I agree with @SergioGiusti's thought almost. Please set the OnSelect property of the "Save"  button to following formula:

Patch(
  '[dbo].[YourSQLTable]',
   Defaults('[dbo].[YourSQLTable]'),
   {
    Checkbox1Column: If(Checkbox1.Value=true, "OK", "NO"),
    Checkbox2Column: If(Checkbox2.Value=true, "OK", "NO"),
    Checkbox3Column: If(Checkbox3.Value=true, "OK", "NO"),
    ...
   }
)

If you want to update corresponding column value of an existing record for that Checkbox, you must find the record you want to update firstly (using LookUp function), then update the record using Patch function. Please take a try with the following formula:

Patch(
  '[dbo].[YourSQLTable]',
   LookUp('[dbo].[YourSQLTable]', SearchColumn="xxx"),   /* <-- find the corresponding record you want to update */
   {
    Checkbox1Column: If(Checkbox1.Value=true, "OK", "NO"),
    Checkbox2Column: If(Checkbox2.Value=true, "OK", "NO"),
    Checkbox3Column: If(Checkbox3.Value=true, "OK", "NO"),
    ...
   }
)

More details about Patch function, please check the following article:

Patch function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
kevinsray
Level: Powered On

Re: Patch Checkbox value as OK when checked

Thank you all for your input.
I have been able to achieve what I was after.


I set each of the checkbox reset value to ResetCheckbox

 

Then put this in the OnSelect
UpdateContext({ResetCheckbox:true});
UpdateContext({ResetCheckbox:false});

 

This worked a treat.
Thank you all for your input.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,987)