cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

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
Highlighted
Helper III
Helper III

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
Highlighted
Kudo Collector
Kudo Collector

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.

Highlighted
Community Support
Community Support

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.
Highlighted
Helper III
Helper III

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,960)