# OPC tag value change upon opening a perspective session

**URL:** <https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499>\
**Category:** Ignition\
**Tags:** opcua, perspective, ignition81\
**Created:** [September 9, 2025, 6:37pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499 "2025-09-09T18:37:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 9, 2025, 6:37pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/1 "2025-09-09T18:37:57Z")

</div>

Hello…

In a project I inherited, we have this partcount INT tag configured with a COUNT query binding (SQL) populating the tag. I monitor that tag in the PLC to do other stuff.

Whenever the perspective session is opened, the tag briefly (half a sec) goes to zero and returns to it’s actual value. Tag group config looks like below:

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

Please throw some light on what might be going on. Thanks!

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [September 9, 2025, 6:45pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/2 "2025-09-09T18:45:10Z")

</div>

Inspect the session event scripts. There may be something in the session startup event that is writing to your tag.

> **[Perspective Session Event Scripts | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/scripting-in-perspective/perspective-session-events-scripts)**
>
> Perspective offers a collection of Session Events designed to allow the Gateway to track and interact with the Session at critical moments. Specifically, they are scripts that run in the Gateway when a Session starts up, shuts down, or runs a...

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 9, 2025, 7:06pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/3 "2025-09-09T19:06:10Z")

</div>

Also look for bidirectional bindings in the UI to that tag. They are known to sometimes misbehave on startup. /:

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [September 9, 2025, 7:24pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/5 "2025-09-09T19:24:34Z")

</div>

Is this change script on a numeric entry field? If it is, you might want to ignore all value changes except those originating from `Browser`, that should make sure it only fires when a user enters something.

> **[Perspective Property Change Scripts | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/ignition-modules/perspective/scripting-in-perspective/perspective-property-change-scripts#origin)**
>
> With Perspective, individual component properties can have a property change script. When a change script is set up on a property, it will run when the property changes its value. Multiple different properties on the same component can each have...

For maintenance sake I would suggest the following improvements:

Make style classes for the different states of the header, and use a map transform to set the style class of the header based on the value of the property with this change script. Or just put an expression binding on the `styles.backgroundColor` property of the header, if you feel lazy.

The value driving this property change(or at least its source) should be in the view custom properties.

The header text should just be an expression binding.

Change the

```python
else:
    if self.props.value >= 512:

```

in the script to be

```python
elif self.props.value >= 512:

```

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 9, 2025, 7:28pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/6 "2025-09-09T19:28:37Z")

</div>

@ryan.white Correct. This is from a query binding populating a numeric entry field

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [September 9, 2025, 7:36pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/7 "2025-09-09T19:36:08Z")

</div>

Are you expecting it to only write/update tag values if the user has entered something? Or do you also want it to write/update if the value from the query changes?

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 9, 2025, 7:38pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/8 "2025-09-09T19:38:55Z")

</div>

Right now it updates only if the query result changes. That part is fine.

My only concern is the PartCount tag going to zero and reverting back to it’s actual value when a session is opened for that project

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [September 9, 2025, 7:45pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/9 "2025-09-09T19:45:23Z")

</div>

> [@Sweetz](#):
>
> updates only if the query result changes

This is not the place for this script then. This script will fire on _every_ open perspective session running this project whenever the query result changes.

> [@Sweetz](#):
>
> when a session is opened

This is likely from the value changing from its uninitialized or default value to the value returned by the query, which will trigger the change script.

You may need to change your script to ignore the initial transition from default to actual.

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [September 9, 2025, 7:57pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/10 "2025-09-09T19:57:24Z")

</div>

> [@ryan.white](#):
>
> This script will fire on _every_ open perspective session running this project.

Why do you think it runs everytime a session opens?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [September 9, 2025, 8:02pm UTC](https://forum.inductiveautomation.com/t/opc-tag-value-change-upon-opening-a-perspective-session/110499/11 "2025-09-09T20:02:33Z")

</div>

> [@ryan.white](#):
>
> value changing from its uninitialized or default value to the value returned by the query,

Properties with bindings will either load with an uninitilized or default value on session startup and await their binding to return an actual value, and switch to that value once received. That transition will trigger a value changed script.
