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

Checkbox and datasource

I have my check box field types set as "bit" in sql tables. How should I declare those in the patch()?

 

Any help is much appreciated!!

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Checkbox and datasource

Hi @asdeev,

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

Could you please show more details about the Patch() function that you mentioned?

Further, where do you put the Checkbox control? Within a Gallery?

The SQL Bit type is a Integer Data Type which can take a value of 0, 1, or NULL.

I suppose that you want to change the Bit field value in your SQL table via checking/unchecking the Checkbox control, is it true?

If you add the Checkbox control within a Gallery, I have made a test on my side, please take a try with the following workaround:

Set the Default property of the Checkbox control (Checkbox1) within the Gallery to following:

If(ThisItem.BitFiled=0,false,true)

Set the OnSelect property of the Checkbox control (Checkbox1) to following:

If(
    Checkbox1.Value=true,
    Patch(
        'YourDataSource',
         ThisItem,
         {
             BitField: 1
         }
    ),
    Patch(
        'YourDataSource',
         ThisItem,
         {
             BitField: 0
         }
    )
)

Note: Type Patch formula within OnCheck or OnUnCheck property of the Checkbox control may cause an issue.

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.
2 REPLIES 2
Super User
Super User

Re: Checkbox and datasource

@asdeev,

I am not an expert in sql but I believe it is 0 for no, and 1 for yes.  For the Checkboxes you would use the OnCheck and OnUncheck properties to patch the underlying field in the table. If the checkbox was in a gallery the OnCheck property would be Patch(sqltable,ThisItem,{fieldname:1}) and the Uncheck Property would be Patch(sqltable,ThisItem,{fieldname:0}).  My experience was in MS Access WebApps (Sql azure backend) and they had a Yes/No field that reduced to 1 and 0.  The ThisItem part of the Patch command would be the identifier for the record in the Sql table. 

Community Support Team
Community Support Team

Re: Checkbox and datasource

Hi @asdeev,

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

Could you please show more details about the Patch() function that you mentioned?

Further, where do you put the Checkbox control? Within a Gallery?

The SQL Bit type is a Integer Data Type which can take a value of 0, 1, or NULL.

I suppose that you want to change the Bit field value in your SQL table via checking/unchecking the Checkbox control, is it true?

If you add the Checkbox control within a Gallery, I have made a test on my side, please take a try with the following workaround:

Set the Default property of the Checkbox control (Checkbox1) within the Gallery to following:

If(ThisItem.BitFiled=0,false,true)

Set the OnSelect property of the Checkbox control (Checkbox1) to following:

If(
    Checkbox1.Value=true,
    Patch(
        'YourDataSource',
         ThisItem,
         {
             BitField: 1
         }
    ),
    Patch(
        'YourDataSource',
         ThisItem,
         {
             BitField: 0
         }
    )
)

Note: Type Patch formula within OnCheck or OnUnCheck property of the Checkbox control may cause an issue.

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.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 289 members 3,991 guests
Please welcome our newest community members: