I recently created a blog post where I detailed how to build a Donut Chart component. In that blog, I noted that I couldn’t use the Color data type because there was no way to get the Color Hex code which I needed for my SVG code.
After some playing around, I discovered a “hack” today that allows me to convert a color value to color hex code (e.g. #3860b2ff)
The solution relies on three functions: JSON(), Char() and Substitute().
First, the JSON() function “converts” the color value (in this example, returned by the button’s Fill property). JSON() returns the color hex code including the Red, Green, Blue and Alpha values wrapped in quotes (i.e. “#8dc63fff”)
Here’s the code:
Set( glbColorHex, Substitute( JSON( Button1.Fill, JSONFormat.IgnoreUnsupportedTypes ), Char(34), "" ) )
Note, the JSON function only works in a behavior property (e.g. OnSelect).