System tags not writing to DB on tag value change

Hi, I'm inserting data to a DB on tag value changed. The tag below isn't writing to the DB and shows as Null.
UserName = system.tag.readBlocking("[System]Client/User/Username")[0].value

All other tags (from default tag provider) are writing to the DB correctly, except for this one.

The correct syntax would be something like:

UserName = system.tag.readBlocking(["[System]Client/User/Username"])[0].value

edit: nevermind, there's a special exception that allows the scalar input value to work in addition to the list. It's what Paul asked about the scope.

Be more specific about where you're calling this from. As in, literally on a tag's event script valueChanged? Because you can't read the client user name from that scope - you're in the wrong place.

1 Like

Yes, I'm on the tag's event script value changed. That would explain. Thanks. Would that need to be done on the Client Event Scripts with Tag Change?

1 Like

Yes, that's the easiest way to get that info. Note that you won't be able to attest, for instance, that the tag was modified by the user in question - that event will fire once per open client whenever the specified tag(s) change.