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

What column type to use as boolean supported by Power Apps

I am trying to create a custom column in Dataverse to store a boolean value. I'm making a power app which pulls the value from Dataverse to set the position of a toggle (all good so far), then I'd like another control to be able to change the value of the toggle (this is where it breaks). This is the logic I have so far:

 

PowerApp page:

OnVisible = Set(varBooleanTest, selectedProfile.Selected.'booleanTest')

*Note, "selectedProfile" is a dropdown which is connected to the dataverse table with the boolean value. The column booleanTest is a Yes/No column 

 

toggle_1:

Default = varBooleanTest

 

Now when I open the page, the toggle is set to the value from the table which is selected in the dropdown - all good so far. I then add another toggle which has overarching control in my context. The functionality I want is when the toggle is switched off, it also turns off the toggles under it, including toggle_1. So, what I've tried is:

 

toggle_2:

OnUnCheck = set(varBooleanTest,false)

 

And here is where I get my error:

lachlanP_0-1635953930828.png

 

Now when I back up to the OnVisible formula, I can see that it no longer likes how the data was brought in. It looks like it cant detect the data type as boolean.

lachlanP_1-1635954100399.png

More proof to that theory:

lachlanP_2-1635954185152.png

 

So my question is, is there a column type I can use in DV which PowerApps recognizes as boolean? Here is what I've tried with no success:

 

  • Using a yes/no column with the items set to "true" and "false" lachlanP_3-1635954290586.png

     

  • Using a yes/no column with different string values, then assigning them to boolean in PowerApps:
    • Data type - Yes/No
    • Items - Enabled, Disabled
    • In PowerApps OnVisible = Set(varBooleanTest, If(selectedProfile.Selected.booleanTest = 'enabled',true,false));
    • This fails as selectedProfile.Selected.booleanTest is not a recognised data type able to be evaluated
  • I've tried the same method as above with both "Choice" and "Choices" column types, trying to switch a string value to boolean in PowerApps and get the same error

 

Hopefully this is possible as it seems like pretty simple functionality to be able to pass a boolean column type to PowerApps!

 

Thanks in advance for the help.

2 ACCEPTED SOLUTIONS

Accepted Solutions
dpoggemann
Super User
Super User

Hi @lachlanP ,

 

Take a look at this article, I think it will help you with your situation on the form...  I have used in the past as well.

https://thepoweraddict.com/y-yes-no-data-card-in-power-apps-for-better-ux/ 

 

Hope this helps.  Please accept if answers your question or Like if helps in any way.


Thanks,

Drew

Hope this helps. Please accept if answers your question or Like if helps in any way.
Thanks,
Drew

View solution in original post

@dpoggemann 

 

This post was the ticket! Thank you!

 

The key was how I evaluated the yes/no column from dataverse. Where I tried to compare to either a boolean value or a text value, it works when formatted as below:

Set(varBooleanTest, If(selectedProfile.Selected.booleanTest = 'booleanTest (IoT Device Profiles)'.Yes, true, false));

 

Where (IoT Device Profiles) is the name of the Dataverse table. Now when I use above as the OnVisible formula, it basically converts this value to boolean.

View solution in original post

4 REPLIES 4
dpoggemann
Super User
Super User

Hi @lachlanP ,

 

Take a look at this article, I think it will help you with your situation on the form...  I have used in the past as well.

https://thepoweraddict.com/y-yes-no-data-card-in-power-apps-for-better-ux/ 

 

Hope this helps.  Please accept if answers your question or Like if helps in any way.


Thanks,

Drew

Hope this helps. Please accept if answers your question or Like if helps in any way.
Thanks,
Drew
v-qiaqi-msft
Community Support
Community Support

Hi @lachlanP,

Do you want to transfer boolean value from Dataverse Yes/No column to Power Apps?

Could you please share  a bit more about your scenario?

 

Actually, you are right that there is no way to transfer boolean value from Yes/No column in Dataverse to Power Apps.

You should know that selectedProfile.Selected.'booleanTest' always returns a text value instead of a boolean value which explains why the data type incompatible when you set the variable on the OnUncheck property of the Toggle.

 

In addition, the Toggle control has its own Default property, which is usually false. So if you set the variable in the OnUncheck property, it will cause an error like invoke issue. The OnUncheck property of the Toggle may not trigger the variable even though it is unchecked because it has false as its Default property value.

 

As an alternative solution, I think a Text column in Dataverse table would be a better choice.

You could set the toggle_2 OnSelect property as below:

Set(varboolean,Toggle_2.Value)

Set the toggle_1 Default property as below:

If(varboolean=false,false)

 

To save the value to your Text column, just need to refer to the Toggle.Value.

Hope this could help you at some degree.

 

 

Best Regards,
Qi

@v-qiaqi-msft ,

 

Yes, what I am trying to do is transfer a boolean value from Dataverse to Power Apps (using whatever column type I can). 

 

You stated that selectedProfile.Selected.'booleanTest' will always return a text value from a yes/no column in Dataverse, but then why doesnt it work to convert this to a boolean in Power Apps using:

set(varBooleanTest, if(selectedProfile.Selected.'booleanTest' = "yes", true, false))

 

Instead I get an error on the "=" character stating that the evaluation is of incompatible types. It seems that the type for a yes/no column is useable in some cases, but not recognized in others. 

 

I arrived at the same conclusion that the best work-around is to use a true text column in Dataverse, then I am converting to boolean in Power Apps using the method above. The problem with this is the functionality loss in Dataverse - I now have an uncontrolled text column which is prone to error rather than a simple boolean column. 

 

I found this idea posted already with unfortunately no votes, it seems to be referring to the same issue I am dealing with (the fact that there is not a true boolean column type in dataverse):

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/Add-quot-real-quot-boolean-field-type-to-Datave...

@dpoggemann 

 

This post was the ticket! Thank you!

 

The key was how I evaluated the yes/no column from dataverse. Where I tried to compare to either a boolean value or a text value, it works when formatted as below:

Set(varBooleanTest, If(selectedProfile.Selected.booleanTest = 'booleanTest (IoT Device Profiles)'.Yes, true, false));

 

Where (IoT Device Profiles) is the name of the Dataverse table. Now when I use above as the OnVisible formula, it basically converts this value to boolean.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (3,336)