4/19/2025 5:55 AM | |
Joined: 10/25/2016 Last visit: 4/30/2025 Posts: 1 Rating:
|
Hello, I am after some help with reading the most recent line from the Audit Trail/Viewer. I am using TIA V19 and have a MTP1900. I wasn't sure if this was possible, but I came across a snippet that I believe provides what I'm looking for. The problem is that I'm not very skilled in JavaScript, and I would appreciate some guidance on how to read and write this information into a tag. HMIRuntime.Trace("Timestamp: " + (new Date(electronicRecord.TimeStamp)).toString() + "\tObjectName: " + electronicRecord.ObjectName + "\tOldValue: " + electronicRecord.OldValue + "\tNewValue: " + electronicRecord.NewValue); Or if there is another way to get this information. Many thanks in advance. Chris AttachmentSnippets.zip (126 Downloads) |
4/22/2025 4:49 AM | |
Joined: 3/22/2022 Last visit: 9/4/2025 Posts: 6 Rating:
|
Hey, I think the code you have writes all the records to the the HMIRuntime Trace Viewer (RTILtraceTool.exe). This should be able to be modified to get what you need. I believe if you get all the entries from page 0, you should be able to just take the first element and it will give you the most recent line.
To write it to a tag you can use Tags("$Insert Tag Name here$").Write("$Insert Audit Text Here$").
I wrote this based on the documentation found here: https://docs.tia.siemens.cloud/r/en-us/v20/wincc-unified-javascript-object-model-rt-unified/hmiruntime-rt-unified/audit-rt-unified/sysfct-rt-unified/sysfct.readelectronicrecord-rt-unified Which mentions that the .Values is an Object of type HMIElectronicRecordValueResult[], e.g. an array that can be indexed at 0 to get the first element.
I haven't tested it though, so let me know if it works or you need a better explanation! |
Last edited by: Moderator_Lan at: 04/22/2025 07:10:26Text formatting optimized |
|
Follow us on