Username Tag to Hold Current Session User

What is the best strategy to document the current user of a perspective session in a tag? I will use the tag in a transaction group.

I've experimented with a runScript() expression inside the UDT with this

[ x['username'] for x in system.perspective.getSessionInfo(projectFilter = project) if(address == x['clientAddress'] ) ]

It seems to run around 30ms, which I believe Phil would object to using with runScript()

Next, would be the same as above, but put in a timer script looping through all sessions of the particular project and system.tag.writeBlocking().

A change script on the userName auth prop doesn't seem to work, neither does startup and shutdown events.

Why in a tag? What happens if two users open the application?

It filters on the address. The project will be open on multiple clients in kiosk mode where each client has it's own UDT where one of the tags is the client username.

1 Like

The other way is to create a custom prop on a view bound to auth.userName with a change script that writes to the UDT tag.

Move your runScript to a project library and call it from a timer event every ten/twenty/thirty seconds. Write the result to a memory tag.

Definitely doesn't belong in an expression tag.

If you have multiple places where this information is needed, do all of them in the same loop.

1 Like