Search code examples
powerappspowerapps-canvas

How to set a color as a global variable in PowerApps?


I am trying to set predefined colors in PowerApps using the function Set, however, when I check the variables tab the variable does not have a value (NA).

The syntax on the option OnStart I am using is as follows:

Set(LightOrange, ColorValue("#ee7f00"))

Can anyone help me solve this issue?


Solution

  • Nothing wrong in what you're doing. You cannot see that LightOrange variable value what you're setting in OnStart under Variables area like debug mode.

    I'm seeing arunColor variable with No value. enter image description here

    I'm assigning #0000ff (Blue) using Set from App OnStart enter image description here

    I'm assigning that variable value arunColor as control color Fill enter image description here

    I'll use one of these urls to access the App after save & publish.

    https://apps.powerapps.com/play/d68b7936-xxxx-xxxx-xxxx-ce064e3f1637
    https://apps.powerapps.com/play/d68b7936-xxxx-xxxx-xxxx-ce064e3f1637?tenantId=e485c427-xxxx-xxxx-xxxx-add2e5942a49
    

    Voila! I see the control color changed. enter image description here

    Reason:
    OnStart is designed to trigger when the app is opened very first time. If you make changes in color, then you have to open the App again to see the changes.