# Script is not reading

**URL:** <https://forum.inductiveautomation.com/t/script-is-not-reading/112695>\
**Category:** General Discussion\
**Created:** [December 9, 2025, 9:28am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695 "2025-12-09T09:28:51Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![duraisundar.a](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@duraisundar.a](https://forum.inductiveautomation.com/u/duraisundar.a)\
**Post date:** [December 9, 2025, 9:28am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/1 "2025-12-09T09:28:51Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/9/e9b7910e34cc9772587f1f646383e551820cb7c6.png)

---

<div class="post-metadata">

**Author:** ![duraisundar.a](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@duraisundar.a](https://forum.inductiveautomation.com/u/duraisundar.a)\
**Post date:** [December 9, 2025, 9:29am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/2 "2025-12-09T09:29:14Z")

</div>

def transform(self, value, quality, timestamp):  
"""  
Expects `value` to be a status string:  
"Alert", "Running", "not\_entry", "entry"

```python
Returns a dict with 'text' and 'style' keys for Perspective binding.
"""

# Normalize input to avoid case/spacing issues
status_key = str(value).strip().lower()

if status_key == "alert":
    status = "Alert"
    bg, fg = "#FF0000", "#FFFFFF" # red
elif status_key == "running":
    status = "Running"
    bg, fg = "#00A000", "#FFFFFF" # green
elif status_key == "not_entry":
    status = "Product Take out Permitted"
    bg, fg = "#FFD54F", "#212121" # yellow
elif status_key == "entry":
    status = "Product Entry Permitted"
    bg, fg = "#ADD8E6", "#073042" # light blue
else:
    status = "Idle"
    bg, fg = "#BDBDBD", "#212121" # neutral default

return {
    "text": status,
    "style": {
        "backgroundColor": bg,
        "color": fg,
        "fontWeight": "bold"
           }

```

---

<div class="post-metadata">

**Author:** ![duraisundar.a](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@duraisundar.a](https://forum.inductiveautomation.com/u/duraisundar.a)\
**Post date:** [December 9, 2025, 9:29am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/3 "2025-12-09T09:29:54Z")

</div>

can some one help on this

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 9, 2025, 9:32am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/4 "2025-12-09T09:32:45Z")

</div>

You can put all the info in the original post.. You can also edit posts.

Also you haven’t told us what the issue is. There’s no error in your screenshot..

Also also, you need to edit your post with the code and fix it up as you didn’t copy it into the code block properly. Take some time to get your info correct so we can help you.

---

<div class="post-metadata">

**Author:** ![duraisundar.a](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@duraisundar.a](https://forum.inductiveautomation.com/u/duraisundar.a)\
**Post date:** [December 9, 2025, 9:47am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/5 "2025-12-09T09:47:54Z")

</div>

there is no error in the code but in front end we are not able to see the colour changes in the label text

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [December 9, 2025, 9:57am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/6 "2025-12-09T09:57:03Z")

</div>

Show us the binding in the props.

---

<div class="post-metadata">

**Author:** ![Cose\_Peter1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cose_peter1/32/79174_2.png) [@Cose\_Peter1](https://forum.inductiveautomation.com/u/Cose_Peter1)\
**Post date:** [December 9, 2025, 10:20am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/7 "2025-12-09T10:20:27Z")

</div>

> [@duraisundar.a](#):
>
> see the colour changes in the label text

You have also not provided any context on what event should the colour change be triggered.

You can try to do a `system.prespective.print("status_key "+str(status_key))` on you script to see if your binding is getting triggered at all.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 9, 2025, 12:43pm UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/8 "2025-12-09T12:43:34Z")

</div>

You cropped out the context of the binding screenshot, ie. What is the binding being applied to? The output looks wrong. You seem to be outputting some styles **and a text key** which seems like the wrong part.

Anyway, show us what that binding is bound to.

Pretend that we don’t know your project, what’s in your head, and what you can see, because most of us can't 👀

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [December 10, 2025, 5:43am UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/9 "2025-12-10T05:43:32Z")

</div>

> [@duraisundar.a](#):
>
> there is no error in the code

Are you sure? When a script doesn't seem to run in Perspective, an exception is what I usually find. Double check the logs or add a temporary label to the project to send diagnostic data to. You could also wrap the whole script in a try/except block, and send the exception to the print console using `system.perspective.print`

I can see in your posted code block that you're missing a closing bracket on your return value:

```python
return { # first open bracket
    "text": status,
    "style": { # second open bracket
        "backgroundColor": bg,
        "color": fg,
        "fontWeight": "bold"
           } # first closing bracket
	#} # missing second closing bracket

```

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [December 10, 2025, 2:38pm UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/10 "2025-12-10T14:38:17Z")

</div>

Script transforms are very inefficient compared to Expressions. I would make that two separate Expression transforms, one on each property of the style. So for the background:

```python
if(lower({this.props.text}) = 'alert', // red
	'#FF0000',
	if(lower({this.props.text}) = 'running', // green
		'#00A000',
		if(lower({this.props.text}) = 'not_entry',	// yellow
			'#FFD54F',
			if(lower({this.props.text}) = 'entry',	// light blue
				'#ADD8E6',
				'#BDBDBD' // default
			)
		)
	)
)

```

You might not notice a difference for a single label, but if you take the script approach for everything, you’ll definitely see a performance hit.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [December 10, 2025, 3:49pm UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/11 "2025-12-10T15:49:40Z")

</div>

> [@Ryan\_Deardorff](#):
>
> Script transforms are very inefficient compared to Expressions.

This, but use a `case` expression instead of nested `if`s, and return a style class name instead of multiple bindings.

---

<div class="post-metadata">

**Author:** ![Ryan\_Deardorff](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan_deardorff/32/63815_2.png) [@Ryan\_Deardorff](https://forum.inductiveautomation.com/u/Ryan_Deardorff)\
**Post date:** [December 10, 2025, 3:55pm UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/12 "2025-12-10T15:55:08Z")

</div>

How on Earth did I not know about `case`? See, that’s why I keep browsing these posts. It took me a year or so before I learned about the performance issue with scripts…

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 10, 2025, 9:31pm UTC](https://forum.inductiveautomation.com/t/script-is-not-reading/112695/13 "2025-12-10T21:31:05Z")

</div>

> [@Ryan\_Deardorff](#):
>
> ```python
> if(lower({this.props.text}) = 'alert', // red
> '#FF0000',
> if(lower({this.props.text}) = 'running', // green
> '#00A000',
> if(lower({this.props.text}) = 'not_entry',	// yellow
> '#FFD54F',
> if(lower({this.props.text}) = 'entry',	// light blue
> '#ADD8E6',
> '#BDBDBD' // default
> )
> )
> )
> )
> 
> ```

Also, if you _do_ need to use nested ifs, maybe it’s just preference, but I find it much easier to read when all the conditions and outputs align (and colours are in human-readable HSL):

```python
if(lower({this.props.text}) = 'alert', // red
	'hsl(7 95% 60%)',
if(lower({this.props.text}) = 'running',	// green
	'hsl(95 60% 60%)',
if(lower({this.props.text}) = 'not_entry',	// yellow
	'hsl(55 95% 60%)',
if(lower({this.props.text}) = 'entry', // light blue
	'hsl(185 95% 60%)',

	'hsl(0 0% 60%)' // default
))))

```

Of course, using magic colours like this is also a no-no and these should use css variables, and I much prefer to reference these inside p.styles and use the p style in the ui, as then they're selectable.

Also, I made an HSL cheat sheet to help remember the H values

> [@Useful CSS Stuff](https://forum.inductiveautomation.com/t/useful-css-stuff/95414/63):
>
> I've added this to a few posts now before realising it really belongs here… I made an HSL cheat sheet in Perspective to help remember the Hue values in the human-readable HSL colour format (as opposed to the mostly human-illegible RGB): View Exports: [HSL Cheat Sheet.zip](https://forum.inductiveautomation.com/uploads/short-url/t5zmywFce0rkswWMZScggxTYxpg.zip) (27.8 KB)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/3/b32566a422bd59407457dba4b5b3f3964d85442b.png)
