1

enter code hereIs it possible to generate a variable or object dynamically? I store some settings like standard colors in a sharepoint list (PowerAppStyling) and read this to dynamically style all my apps.

Like:

Object,Property,Value
Label,Font,Segoe UI
Label,Fill,White
Label,Color,Grey

This is working fine, I can set the label font like this:

First(Filter(PowerAppStyling,Object = "Label" && Property = "Font")).Value

Now, to make this more easier to read, from the list above, I would like to dynamically, runtime create an object something like this: PowerAppStyling.Label.Font that should give a value of "Segoe UI" or a simple variable where I concatenate the columns, like LabelFont.

I tried the Set() function:

Set(a,"a");Set(b,"b");Set(concatenate(a,b),"ab")

I expected that the 3rd command will create a variable named ab and set its value to "ab", but t doesn't accept strings in variable names.

Is any of the two option possible, if yes, how?

vilmarci
  • 451
  • 10
  • 31

1 Answers1

0

The second option definitely is not possible today - you can consider creating a new feature request in https://aka.ms/powerapps-ideas for that.

For the first option, if you know all the fields that the 'PowerAppsStyling' object will have, then you can at the beginning of your app (e.g., on the App.OnStart logic) read the values from your settings SP list and create the object, so that you can use it throughout the app, something along the lines of

ClearCollect(localStylesTemp, PowerAppsStyling); // To make only 1 network call to the SP list
Set(
    LocalStyles,
    {
        Label: {
            Font: LookUp(localStylesTemp, Object = "Label" And Property = "Font", Value),
            Fill: LookUp(localStylesTemp, Object = "Label" And Property = "Fill", Value),
            Color: LookUp(localStylesTemp, Object = "Label" And Property = "Color", Value)
        },
        Button: {
            Font: LookUp(localStylesTemp, Object = "Button" And Property = "Font", Value),
            Fill: LookUp(localStylesTemp, Object = "Button" And Property = "Fill", Value),
            Color: LookUp(localStylesTemp, Object = "Button" And Property = "Color", Value)
        }
    })

After that you can reference LocalStyles.Label.Font in your app.

Hope this helps!

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • Thanks. Though, this is not completely what I wanted (my goal was to have all objects and property name dynamic), but I understand that this is the most that is currently possible. – vilmarci Apr 01 '20 at 13:40