web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Apps
Answered

TwoOptions Bug

(0) ShareShare
ReportReport
Posted on by 203

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/property#remarks

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

 

 

I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

    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?

  • rexkenley Profile Picture
    203 on at

    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

     









  • cchannon Profile Picture
    4,702 Moderator on at

    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).

  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    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

     

  • rexkenley Profile Picture
    203 on at

    @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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 839

#2
Valantis Profile Picture

Valantis 533

#3
Haque Profile Picture

Haque 412

Last 30 days Overall leaderboard