cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
R3dKap
Level 10

Zoom and FormMode enums data-type differ from other enums in PowerApps

Hi,

 

When you use the ClearCollect (or Collect) functions to create a collection, in all records of the collection, properties with the same name must be of same data type.

In other words, the following code...

ClearCollect(
    {
        name: "Height",
        value: 300
    },
    {
        name: "Text",
        value: "Default text"
    }
)

...leads to an error because the value property cannot be an integer in one record and a string in another one.

 

I created a collection regrouping all controls enums in PowerApps:

ClearCollect(
    gloControlEnums,
    {
        name: "Font",
        values: Table(
            {
                name: "Arial",
                value: Font.Arial
            },
            {
                name: "Courier New",
                value: Font.'Courier New'
            },
            {
                name: "Dancing Script",
                value: Font.'Dancing Script'
            },
            {
                name: "Georgia",
                value: Font.Georgia
            },
            {
                name: "Great Vibes",
                value: Font.'Great Vibes'
            },
            {
                name: "Lato",
                value: Font.Lato
            },
            {
                name: "Lato Black",
                value: Font.'Lato Black'
            },
            {
                name: "Lato Hairline",
                value: Font.'Lato Hairline'
            },
            {
                name: "Lato Light",
                value: Font.'Lato Light'
            },
            {
                name: "Open Sans",
                value: Font.'Open Sans'
            },
            {
                name: "Open Sans Condensed",
                value: Font.'Open Sans Condensed'
            },
            {
                name: "Patrick Hand",
                value: Font.'Patrick Hand'
            },
            {
                name: "Segoe UI",
                value: Font.'Segoe UI'
            },
            {
                name: "Verdana",
                value: Font.Verdana
            }
        )
    },
    {
        name: "FontWeight",
        values: Table(
            {
                name: "Bold",
                value: FontWeight.Bold
            },
            {
                name: "Semibold",
                value: FontWeight.Semibold
            },
            {
                name: "Normal",
                value: FontWeight.Normal
            },
            {
                name: "Lighter",
                value: FontWeight.Lighter
            }
        )
    },
    {
        name: "BorderStyle",
        values: Table(
            {
                name: "None",
                value: BorderStyle.None
            },
            {
                name: "Dashed",
                value: BorderStyle.Dashed
            },
            {
                name: "Dotted",
                value: BorderStyle.Dotted
            },
            {
                name: "Solid",
                value: BorderStyle.Solid
            }
        )
    },

etc...

What is really strange is that among the 21 enums in PowerApps, two of them won't fit into the collection above:

  • Zoom (in the PDF Viewer control)
  • FormMode (in the Edit Form control)

I assume this is due to the fact that, for some strange reason, the data type of these 2 enums differ from all 19 others. PowerApps shows this error when adding one of these 2 enums to my collection above:

 

Image 4.png

 

Anyone from the PowerApps team can help me on this ?

 

Thanks,

 

Emmanuel

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Zoom and FormMode enums data-type differ from other enums in PowerApps

The members of PowerApps enumerations can be either strings or numbers. The easiest way to find out which is which is to use a label to look at the enum value:

ForumPost001.PNG

or

ForumPost002.PNG

If you want to have a collection with all enums in PowerApps, you can convert the numeric ones to text, using the Text function:

ClearCollect(
    gloControlEnums,
    {
        name: "FontWeight",
        values: Table(
            { name: "Bold", value: FontWeight.Bold },
            { name: "Semibold", value: FontWeight.Semibold },
            { name: "Normal", value: FontWeight.Normal },
            { name: "Lighter", value: FontWeight.Lighter }
        )
    },
    {
        name: "Zoom",
        values: Table(
            { name: "FitBoth", value: Text(Zoom.FitBoth) },
            { name: "FitHeight", value: Text(Zoom.FitHeight) },
            { name: "FitWidth", value: Text(Zoom.FitWidth) }
        )
    }
)

Notice that there are many other numeric enumerations in PowerApps (StartOfWeek, ErrorKind, PDFPasswordState, LoadingSpinner, ...)

Hope this helps!

View solution in original post

4 REPLIES 4
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Zoom and FormMode enums data-type differ from other enums in PowerApps

The members of PowerApps enumerations can be either strings or numbers. The easiest way to find out which is which is to use a label to look at the enum value:

ForumPost001.PNG

or

ForumPost002.PNG

If you want to have a collection with all enums in PowerApps, you can convert the numeric ones to text, using the Text function:

ClearCollect(
    gloControlEnums,
    {
        name: "FontWeight",
        values: Table(
            { name: "Bold", value: FontWeight.Bold },
            { name: "Semibold", value: FontWeight.Semibold },
            { name: "Normal", value: FontWeight.Normal },
            { name: "Lighter", value: FontWeight.Lighter }
        )
    },
    {
        name: "Zoom",
        values: Table(
            { name: "FitBoth", value: Text(Zoom.FitBoth) },
            { name: "FitHeight", value: Text(Zoom.FitHeight) },
            { name: "FitWidth", value: Text(Zoom.FitWidth) }
        )
    }
)

Notice that there are many other numeric enumerations in PowerApps (StartOfWeek, ErrorKind, PDFPasswordState, LoadingSpinner, ...)

Hope this helps!

View solution in original post

R3dKap
Level 10

Re: Zoom and FormMode enums data-type differ from other enums in PowerApps

Thank you @CarlosFigueira, I'll use the Text() function indeed...

 

Another question/remark: it's interesting to see how you formatted your code in your last post. I would say it's an intermediate format between the FORMAT TEXT function and the REMOVE FORMATTING function that we can find at the bottom of the code editor.

The FORMAT TEXT function produces something like the code I put in my original post (it can then generate very quickly many pages and pages of code) and the REMOVE FORMATTING pretty much does a "minify" on your code (but which is unreadable).

What I want to point out here is that I find the intermediate formatting very handy and easy to read. Do you know if there is any chance that we could use this type of code formatting one day in the code editor ?

Emmanuel

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Zoom and FormMode enums data-type differ from other enums in PowerApps

For my post I did format it "by hand" by removing some lines that I think are too much. I agree with you, this format is more readable than the one that we get with the "Format Text" feature. Can you create a new feature request in the PowerApps Ideas board, I've heard this feedback before, and if we have more people voting up for it (please let me know when you create it and I'll vote for it as well), then it will get a higher priority in the backlog for features.

R3dKap
Level 10

Re: Zoom and FormMode enums data-type differ from other enums in PowerApps

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,088)