Change color of label in scorecard row

I have a scorecard showing a field “Code” and a label “lblCodeColor”. Utimately I want to script to change the color of the label in each row based on what the Code is but I can’t even get the script to just change the color of the label. Normally in a dashboard I would do something like:
lblCodeColor.background = new dundas.controls.SolidColorBrush(“Purple”);
to change the color but this doesn’t seem to work in a scorecard. When I run the above line in the Chrome debugger, it does work, but it does not work in the actual scorecard. Any help anyone can give? Thanks.

Have you tried States?

Also on the support site just search States

I was able to get it to work using states. Thank you very much, I had not thought of that. I would still be interested if anyone knows how to access data label properties within a scorecard. I realized that the code above that I use in dashboard does not work because the scorecard body is a repeater. Thanks again for the idea.

It’s possible to use scripts from visual to visual but you should understand that since content is generated on a repeater, it might not be as straightforward depending on the event you use. Otherwise some label in the body could appear 5, 10, 20 times and “lblCodeColor” can’t refer to all of them. If it’s a global event (e.g. Ready) then only labels which can only appear once, such as those in the report header, can be referred to.

Do this in the label’s Data Changed event and that work, as will simply using “this”.

Thank you so much! The Data Changed event is exactly what I needed. I was able to access the data label’s properties and change the color for all of them. Do you know how to access the repeater item controls? My ultimate goal is something like the following code below. lblTest2.control.text is resolving to the [fieldname] as the text, however, not the actual value. I know I need to somehow access the repeater row or container but I can’t figure out that reference. Thanks again!

if(lblTest2.control.text == 400) {
lblTest2.control.background = new dundas.controls.SolidColorBrush(“Purple”);
lblTest2.control.background = new dundas.controls.SolidColorBrush(“Green”);

And the actual programming goal involves many logic branches and many data labels showing various colors based on the options - which is why I was trying to use scripts instead of States. In any case, thanks for the all the tips. It kept me going forward.