Hi, I'm trying to use JSON to convert a Powerapps colour into a hex value. It works if I put the code on a button and set a variable, but for some reason it's giving me an error if I try and put this directly into a text label.
Is this something particular to the JSON function?
Works on a button:
Error in text label:
EDIT:
Wrapping in a With() didn't work.
Thanks for the explanation.
I have experienced non behaviour functions before, like UpdateContext() and understand that they change the state of things. I can't imagine what JSON() is changing, thought it just returned text.
Hello @Chris-D
The issue you're experiencing is rooted in how PowerApps differentiates between "behavior functions" and "non-behavior properties."
In PowerApps, certain functions are classified as "behavior functions." These functions are meant to execute specific actions or side effects, rather than just returning a value. The JSON() function is one of these behavioral functions. It's primarily designed for actions like converting records or tables to a JSON format rather than being used for direct display.
The OnSelect property of a button is a behavioral property, designed to react to user actions. So, when you use the JSON() function within a button's OnSelect property, it works as expected.
However, the Text property of a label is a non-behavior property, which simply binds and displays data. When you attempt to use a behavior function like JSON() directly within a non-behavior property, PowerApps gives an error or doesn't display the desired output.
The recommended workaround for this situation is using this function within within a button or another behavioral property to set a variable. Then, bind this variable to the Text property of your label.Which you already did.
I hope this clarifies the distinction between behavior functions and non-behavior properties in PowerApps. Let me know if you have any further questions!
If my response was beneficial to you, feel free to leave a 👍 symbol. If it effectively resolved your query, please signify with a 👍 and mark it as the Solution, assisting other community members in locating this helpful information more readily.
MS.Ragavendar
32
Michael E. Gernaey
19
Super User 2025 Season 1
Rajkumar_M
16
Super User 2025 Season 1