cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver I
Resolver I

CDS Two Options (number) - Singe Check Box

Hi there,

 

I am creating and app that has an two option field in CDS (the two options are 0 or 1). By default, powerapps shows a dropdown box with the two options. I have figured out how to insert a toggle and i've checked out this answer about inserting 2 checkboxes

https://powerusers.microsoft.com/t5/Building-Power-Apps/How-do-I-make-a-Dropdown-a-checkbox-for-a-Tw... however i would like to just be able to insert one checkbox - if checked it writes back a 1 to the CDS, if unchecked it writes back a 0. Any ideas?

 

Cheers

1 ACCEPTED SOLUTION

Accepted Solutions

Solved this myself - thought i'd share the solution:

 

Change the Checkbox Default to :

If(

ThisItem. 'YourEntityName'='YourEntityName (YourDataSourceName)'.'1',

ThisItem. 'YourEntityName'='YourEntityName (YourDataSourceName)'.'0',

false)

 

Note: if your options are numbers, they must be in single quotation marks.

 

Change the DataCard Update to:

 

If(CheckBoxName.Value,
'YourEntityName (YourDataSourceName)'.'1',
'YourEntityName (YourDataSourceName)'.'0')

View solution in original post

6 REPLIES 6
Super User III
Super User III

Hi @Cym ,

I am not a CDS user, but the below should work.

If you are using SubmitForm on the Update property of the card
If (Checkbox.Value=true,1,0)

 

If Patch

OnCheck patch the CDS record with 1

OnUncheck, Patch the CDS record with 0

 

 

Please click and accept as Solution if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.

Thanks for your  help @WarrenBelz, but i can't seem to get that to work.  Might need some more detailed explanation or different approach?

 

Thanks!

Hi @Cym ,

Just so I make sure I was not ambiguous on this (which is possible):-

  • You have a card with the data source of a numeric field.
  • You have a checkbox in that card (I will call it CheckBox1) that can be checked or not
  • The Update properties of the card is    If (Checkbox.Value=true,1,0)
  • It does not work in CDS

If this is the case, I will leave it to others who will know CDS better.

Sorry I could not assist.

Thankyou, but i can't get it to work - CDS is weird!

Solved this myself - thought i'd share the solution:

 

Change the Checkbox Default to :

If(

ThisItem. 'YourEntityName'='YourEntityName (YourDataSourceName)'.'1',

ThisItem. 'YourEntityName'='YourEntityName (YourDataSourceName)'.'0',

false)

 

Note: if your options are numbers, they must be in single quotation marks.

 

Change the DataCard Update to:

 

If(CheckBoxName.Value,
'YourEntityName (YourDataSourceName)'.'1',
'YourEntityName (YourDataSourceName)'.'0')

View solution in original post

Super User III
Super User III

Hi @Cym ,

I am glad you solved it - also glad I am on SharePoint . . .

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (102,495)