Hello everyone,
I have a weird phenomenon with a tag change client event script in a vision client.
I have an expression tag as the tag change parameter for a client event script. This tag is not changing value (or quality or timestamp but I don’t have those boxes checked), yet when I click a logout button that is in no way connected to the client event script, the client event script fires. I have watched the tag that triggers the event as this happens and there’s no change I can see. The tag is NOT changing value because nothing in the expression for the tag is changing. Is this a bug or am I missing something?
Best,
William
Might be a bug. If you can put together a small reproducer, consider sending it to support.
1 Like
What is a reproducer? Thanks for the response.
A sample project or gateway backup that shows the problem reliably by itself.
1 Like
Update: I believe it is indeed a bug. I have two client event scripts that run on a tag change. I changed the tag parameters that trigger the client event scripts to hardcoded true Boolean memory tags. Therefore, there is no possible way for the tag to change value and trigger the script. However, when I run the following script on a logout button, the client scripts run.
Logout Script that triggers the client event scripts to run:
uname = "Operator"
pwd = "password"
success= system.security.switchUser(uname,pwd)
if not success:
event.source.parent.getComponent("UsernameField").requestFocusInWindow()
I made a support ticket, I hope that’s sufficient. If there are any admins or software developers on here that can help, it would be appreciated.
Thanks.
Use
to format your code
uname = “Operator”
pwd = “password”
success= system.security.switchUser(uname,pwd)
if not success:
event.source.parent.getComponent(“UsernameField”).requestFocusInWindow()
Not quite sure what you are saying - you have two tag change scripts on boolean memory tag (either gateay or client tags - not specified)
The script you list doesn’t write any value to a tag - are you saying those client event scripts that are supposed to only run when the tag turns true also run when that snippet of code on your logout button is pressed? Or that the logout code is running and you’re expecting it to be blocked?
“are you saying those client event scripts that are supposed to only run when the tag turns true also run when that snippet of code on your logout button is pressed?”
Yes. The snippet of code is the script on a logout button (which really just changes users to the lowest setting). When this script runs the tag change event scripts fires (these scripts were not posted). I was told by support that this is how it is suppose to operate. The client instance reinitializes and the tags that fire the client event scripts change from “null/none” to its memory value. However, this was not described in the documentation for client event scripts and if this is how they operate it should be stated as such.
They should be labeled “tag change or change in user client event scripts” or something of that fashion to denote when it will actually fire.
Tag change event scripts have an initialChange
flag that tells you when they are starting and restarting. Check the flag.
2 Likes
Tip: use the </>
code formatting button when pasting code to preserve indentation (which is essential for Python code) and apply syntax highlighting. For short bit’s of inline code you can surround with `` backticks to format it like this
. There’s an edit button (pencil icon) below your post that enables you to fix it. Thanks.
1 Like
You can also encapsulate your code in triple backticks and write the language name after the first series of backticks, like this:
```python
code
```
1 Like
Thanks for the tips everyone!
Hey everyone, support just confirmed that this is a bug and it currently has an internal bug ticket. Thanks everyone for the support.
I realize this thread has a solution but I wanted to report an additional observation regarding Client tags on 8.1.~. We have a client tag tied to an expression evaluating user roles. When we log out and then log back in it updates correctly shown the result of the new user’s roles. However, if we switch user via system.security.switchUser, the client tag does not update. We are opening a case with support.