cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rexkenley
Kudo Collector
Kudo Collector

TwoOptions Bug

I may have found a bug with pcf when it comes to TwoOptions

The documentation states that This column provides two options. Each option has a number value of 0 or 1 corresponding to a false or true value. Each option also has a label so that true or false values can be represented as "Yes" and "No", "Hot" and "Cold", "On" and "Off" or any pair of labels you want to display.
https://docs.microsoft.com/en-us/powerapps/developer/component-framework/manifest-schema-reference/p...

But in the SimpleFormatter.js file, we have this code segment. Since the value is not string, .toLowerCase() would result to a type error.

rexkenley_0-1627063675434.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DianaBirkelbach
Super User
Super User

Hi @rexkenley , 

 

the param .raw is a boolean for a TwoOptions parameter. I guess the docs are referring to the Options that you get, when you consider the param.attributes.Options, which is an array with {Label, Value, Color}. The description is similar to OptionSets too: in that case the value is a number.

 

Regarding the crash in the harness, I don't know how you made it to introduce an integer. The harness is providing a "Select" where you can choose the options True/False. This will pass a boolean to the control.

DianaBirkelbach_0-1627071770655.png

Did you maybe change the type of the parameter ?

In case you set the value to a number, and that broke the harness, there is a workarround for that. Search in the localStorage for http://127.0.0.0:<yourPort> the key <controlName>_properties. There are saved the value for the harness. If you delete that, the harness should be refreshed, and you can start again. In my older blog (the bottom part, about the broken harness ) I have a few details on this: https://dianabirkelbach.wordpress.com/2020/03/22/colorful-optionset-part1/


Hope this helps!

 

Kind regards,

Diana

 

Kind regards,
Diana
----------
Please click "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."

View solution in original post

5 REPLIES 5
cchannon
Memorable Member
Memorable Member

Meh. I mean, it is in an Else branch where the main branch checks typeof == "boolean"

 

Would an actual boolean fail to go to lower case? Yes. But would an actual boolean ever hit that branch? Nope.

 

So, not really a bug, I think. Maybe just a piece that was intended to support more flexible inclusions like the string label not yet parsed to boolean. Nothing wrong with that. Your code doesn't break on it, right?

cchannon,

If you look at the screen shot the value is a number. And the "meh" results to the sandbox "crashing" to a blank screen. It doesn't even load my control. So I still think it's a bug.

rexkenley_0-1627066099017.png

 









huh. OK, well I didn't expect it to actually get a numerical; figured it would be bool or string or nothing.

 

But, you don't really need it anyway. Not sure why they even included it other than a dev sitting around going, "...but I mean, I guess we kinda have to have a boolean type, right?You can just use Enum with only two options. Then you'll have no cast issues; it will simply give you 0 or 1 (or whatever numbers you assign).

DianaBirkelbach
Super User
Super User

Hi @rexkenley , 

 

the param .raw is a boolean for a TwoOptions parameter. I guess the docs are referring to the Options that you get, when you consider the param.attributes.Options, which is an array with {Label, Value, Color}. The description is similar to OptionSets too: in that case the value is a number.

 

Regarding the crash in the harness, I don't know how you made it to introduce an integer. The harness is providing a "Select" where you can choose the options True/False. This will pass a boolean to the control.

DianaBirkelbach_0-1627071770655.png

Did you maybe change the type of the parameter ?

In case you set the value to a number, and that broke the harness, there is a workarround for that. Search in the localStorage for http://127.0.0.0:<yourPort> the key <controlName>_properties. There are saved the value for the harness. If you delete that, the harness should be refreshed, and you can start again. In my older blog (the bottom part, about the broken harness ) I have a few details on this: https://dianabirkelbach.wordpress.com/2020/03/22/colorful-optionset-part1/


Hope this helps!

 

Kind regards,

Diana

 

Kind regards,
Diana
----------
Please click "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."

View solution in original post

@DianaBirkelbach 

 

Thanks! Clearing the cache works.

Although I wonder if this could be considered a "code design bug" considering that both JS and SQL consider 0 to be false. The key value to the "true" option is 0. So you can't use the key value without inverting it, unlike the other types of options where you can use the key values directly.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (4,580)