Perspective Tag Changed By Tracking

Good Afternoon All,

I have a perspective view with a dropdown list that I have assigned to a tag (NewState) and is set to historical which is connected to my Canary Labs Historian. I want to capture the current, logged in user (session.props.auth.user.userName), into another tag (stateChangedBy) when the user has chosen a new value from the dropdown list. Essentially, I am trying to capture who changed the the (NewState) tag in my historian. I have verified that session.props.auth.user.userName gives me the user data I want, and the tag value change from the dropdown list to be trigger of writing the user name to my (StateChangedBy) tag. Additionally, I would like to show the new state value and who changed it in my historical table, which should be good to go when I get the first part working. Any help would be much appreciated, thank you for your time!

Regards,

Tim

I use audit logs for this
Audit Log and Profiles | Ignition User Manual

Hey DK,

Thank you for the quick reply. After reading up about the Audit Log, the user's name that changed the dropdown list tag must also go into my Canary data historian, which I am reading back in my historical table shown. Although I am showing the historical machine state and state changed by in Ignition, there are other audiences that need the data outside of ignition, direct from the Canary Historian through it's visualization web app, Axiom.

Regards,

Tim

The audit log will capture the user as actor. When you create an audit profile, you chose which database the information is stored in. I'm not 100% sure, but you should be able to select Canary as your database target.

Hey DK,

Unfortunately Canary is not an option for an audit log target, because it is time-series and not relational. I have the trigger in place for the drop down and is wiritng to StateChangedBy tag, but I cannot get it to populate with the session.props.auth.user.userName value. I'm sure it's my syntax....

def runAction(self, event):
	tagPath = ["[default]Drill_Room/Hitachi/ND-1V284E/K130877011-K130877022_MAE-E002/StationStateChanged/StateChangedBy"]
	currentUser = session.props.auth.user.userName
	system.tag.writeBlocking(tagPath, currentUser)

Highlight everything after currentUser = and then use the property selector dialog UI on the right to pick it. Then you'll see the nuanced difference.

Thank you so much Phil!!

How the heck would I have found this out on my own? Could you expand on how "self." got me to the proper value write to my tag? Thanks again sir!

def runAction(self, event):
	tagPath = ["[default]Drill_Room/Hitachi/ND-1V284E/K130877011-K130877022_MAE-E002/StationStateChanged/StateChangedBy"]
	currentUser = self.session.props.auth.user.userName
	system.tag.writeBlocking(tagPath, currentUser)

Jython functions get just their arguments, and have just a few other built-ins in scope. session is not a built-in.

In Ignition's expression language, curly braces have more predefined names.

Expressions are not jython, nor vice versa.