# Log Previous Values in Audit Log

**URL:** <https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378>\
**Category:** Ignition\
**Created:** [October 7, 2013, 11:39am UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378 "2013-10-07T11:39:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Duffanator](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/duffanator/32/3560_2.png) [@Duffanator](https://forum.inductiveautomation.com/u/Duffanator)\
**Post date:** [October 7, 2013, 11:39am UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378/1 "2013-10-07T11:39:53Z")

</div>

Hey guys,

It would be nice if, for tag value changes, there was another column in the AUDIT\_EVENTS table that would store the tag value that it was changed from. We’ve had a couple of incidents where someone changed a value or changed a wrong value by accident and it was easy to find out who did it but not what the original value was.

---

<div class="post-metadata">

**Author:** ![onestank](https://avatars.discourse-cdn.com/v4/letter/o/ba9def/32.png) [@onestank](https://forum.inductiveautomation.com/u/onestank)\
**Post date:** [October 17, 2013, 9:34pm UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378/2 "2013-10-17T21:34:25Z")

</div>

I am with you that would be a nice feature.

---

<div class="post-metadata">

**Author:** ![jdefunes](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jdefunes/32/20139_2.png) [@jdefunes](https://forum.inductiveautomation.com/u/jdefunes)\
**Post date:** [December 15, 2020, 7:37am UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378/3 "2020-12-15T07:37:04Z")

</div>

I hope this help somebody.

> SELECT  
> ae.audit\_events\_id,  
> ae.event\_timestamp AS Time,  
> ae.actor AS User,  
> ae.action AS Action,  
> ae.action\_value AS Value,  
> case when ae.action='tag write' then  
> (select oae.action\_value from AUDIT\_EVENTS oae where oae.action=ae.action and oae.action\_target=ae.action\_target and oae.EVENT\_TIMESTAMP\<ae.EVENT\_TIMESTAMP order by oae.EVENT\_TIMESTAMP desc LIMIT 1)  
> else '' end as oldValue,  
> ae.action\_target AS Target,   
> ae.actor\_host AS Host,  
> ae.status\_code AS 'Status Code',  
> ae.originating\_system AS 'System',  
> ae.originating\_context  
> FROM AUDIT\_EVENTS ae  
> ORDER BY  
> ae.audit\_events\_id DESC

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [December 15, 2020, 6:21pm UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378/4 "2020-12-15T18:21:54Z")

</div>

![clapping-icegif-4](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/8/98acca15d032223946be0d76fad8bb7d10df60ea.gif)

This feature should be in it from the begining…

---

<div class="post-metadata">

**Author:** ![Stef\_Velers](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@Stef\_Velers](https://forum.inductiveautomation.com/u/Stef_Velers)\
**Post date:** [December 20, 2023, 10:02am UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378/5 "2023-12-20T10:02:18Z")

</div>

Is there a way to use this but still use Functions so I can filter what kind of tags I want to show in the table? For example, I currently use a date range component to filter the audit table in the client to a certain date and I use a textfield to type a name to filter the target.

But if I also want the old value to be shown with this query then I'm not able to use those functions any more.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/378c77e2c064b94ed984e1a0a3c99954be0a78af.png)

I'm working with Vision.

---

<div class="post-metadata">

**Author:** ![Jonathon\_Taylor](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@Jonathon\_Taylor](https://forum.inductiveautomation.com/u/Jonathon_Taylor)\
**Post date:** [February 24, 2026, 3:22pm UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378/6 "2026-02-24T15:22:27Z")

</div>

It seems it would be easy for IA to update the tag value change audit to include the previous value in the audit log, to include it in the “Value” column; update it so “Value” column has the new, currentValue = newValue and previousValue = oldValue.

In any case, I think the previously shared SQL was for MySQL/PostgreSQL, this SQL works for SQL Server if the previous value exists… :

`SELECT`  
`ae.audit_events_id,`  
`ae.event_timestamp AS [Time],`  
`ae.actor AS [User],`  
`ae.action AS [Action],`  
`ae.action_value AS [Value],`  
`CASE`  
`WHEN ae.action = 'tag write' THEN (`  
`SELECT TOP 1 oae.action_value`  
`FROM AUDIT_EVENTS oae`  
`WHERE oae.action = ae.action`  
`AND oae.action_target = ae.action_target`  
`AND oae.event_timestamp < ae.event_timestamp`  
`ORDER BY oae.event_timestamp DESC`  
`)`  
`ELSE '' -- cast if needed, e.g. CAST('' AS varchar(100))`  
`END AS oldValue,`  
`ae.action_target AS [Target],`  
`ae.actor_host AS [Host],`  
`ae.status_code AS [Status Code],`  
`ae.originating_system AS [System],`  
`ae.originating_context`  
`FROM AUDIT_EVENTS ae`  
`ORDER BY ae.audit_events_id DESC;`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 24, 2026, 3:33pm UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378/7 "2026-02-24T15:33:16Z")

</div>

> [@Jonathon\_Taylor](#):
>
> would be easy

It would not. Auditing is a tag actor, just like history. Tag actors get the new value/timestamp/quality as a QV and nothing else.

The `previousValue` available in scripting is synthesized by the scripting tag actor at the **end** of the pipeline.

---

<div class="post-metadata">

**Author:** ![Jonathon\_Taylor](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@Jonathon\_Taylor](https://forum.inductiveautomation.com/u/Jonathon_Taylor)\
**Post date:** [February 24, 2026, 9:01pm UTC](https://forum.inductiveautomation.com/t/log-previous-values-in-audit-log/7378/9 "2026-02-24T21:01:28Z")

</div>

> [@pturmel](#):
>
> The `previousValue` available in scripting is synthesized by the scripting tag actor at the **end** of the pipeline.

Thanks for the information. It seems like there could be an administrative setting that tells Ignition to log the currentValue and previousValue to the audit table when flagged tags change values, essentially automating logging/auditing for a Value Changed event vs. custom scripting I’ve done for logging the new currentValue and the previousValue.

Maybe not “easy”, though if it’s at the end of the pipeline means the previousValue is available? Why can’t that be automated via Ignition to be written to the audit table?
