# Perspective Auditing

**URL:** <https://forum.inductiveautomation.com/t/perspective-auditing/30781>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [December 17, 2019, 9:41pm UTC](https://forum.inductiveautomation.com/t/perspective-auditing/30781 "2019-12-17T21:41:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard.d.white](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@richard.d.white](https://forum.inductiveautomation.com/u/richard.d.white)\
**Post date:** [December 17, 2019, 9:41pm UTC](https://forum.inductiveautomation.com/t/perspective-auditing/30781/1 "2019-12-17T21:41:27Z")

</div>

Just wanted to share a solution to how to audit/log user actions via perspective. An Ignition rep helped us out with this and I imagine some people may have a similar need/issue.

First thing was that registering perspective user login/logout does NOT work with the default audit database. You need to create your own audit table to do this, so we made a table named PERSPECTIVE\_AUDIT\_TABLE.

To register login/logout user events, in Designer go to Project-\>Session Events-\>Startup (or Shutdown). then you can insert code like we did:

```
userName = session.props.auth.user.userName
action = "Login"
system.db.runPrepUpdate("INSERT INTO PERSPECTIVE_AUDIT_TABLE(ACTOR,ACTION) VALUES (?,?)", [userName, action])	

```

Logging user control changes such as button presses, etc. are done via component event scripting. For example for a slider action we used:

```
userName = self.session.props.auth.user.userName
action = self.view.params.Farm + " " + self.view.params.ControllerName+" forced on for " + str(self.getSibling("NumericEntryField").props.value) + " Minutes"
system.db.runPrepUpdate("INSERT INTO PERSPECTIVE_AUDIT_TABLE(ACTOR,ACTION) VALUES (?,?)", [userName,action])	

```

Anyways we really appreciate the help from the Ignition team and hope this can help other people. Thanks.

---

<div class="post-metadata">

**Author:** ![mstone](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@mstone](https://forum.inductiveautomation.com/u/mstone)\
**Post date:** [April 1, 2020, 1:28pm UTC](https://forum.inductiveautomation.com/t/perspective-auditing/30781/2 "2020-04-01T13:28:47Z")

</div>

This was very handy. I was looking for a good way to handle tag events, this works good. Thanks.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 1, 2020, 3:52pm UTC](https://forum.inductiveautomation.com/t/perspective-auditing/30781/3 "2020-04-01T15:52:19Z")

</div>

Note that first-party Perspective auditing landed in 8.0.8 - login, logout, and security level changes included. Also, 8.0.12 (probably) will have a `system.util.audit()` function available in all scopes.

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [May 2, 2020, 11:35am UTC](https://forum.inductiveautomation.com/t/perspective-auditing/30781/4 "2020-05-02T11:35:16Z")

</div>

Can I ask why don’t you use the perspective audit table for manually insert data and create a new table?

---

<div class="post-metadata">

**Author:** ![richard.d.white](https://avatars.discourse-cdn.com/v4/letter/r/b2d939/32.png) [@richard.d.white](https://forum.inductiveautomation.com/u/richard.d.white)\
**Post date:** [May 4, 2020, 5:54pm UTC](https://forum.inductiveautomation.com/t/perspective-auditing/30781/5 "2020-05-04T17:54:52Z")

</div>

Nader - you’re correct as of right now. However at the time we had the need, the perpective audit table was not yet available.

---

<div class="post-metadata">

**Author:** ![nader.chinichian](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nader.chinichian/32/9261_2.png) [@nader.chinichian](https://forum.inductiveautomation.com/u/nader.chinichian)\
**Post date:** [October 2, 2020, 4:33pm UTC](https://forum.inductiveautomation.com/t/perspective-auditing/30781/6 "2020-10-02T16:33:11Z")

</div>

Hi Paul

Is there any restriction on using system.db.runPrepUpdate("INSERT INTO audit\_events …) in perspective?  
Because I can insert new row in audit table with system.db.runPrepUpdate("INSERT INTO audit\_events …) in vision but it seems it doesn’t work in perspective.  
The reason I don’t use `system.util.audit()’ is this is npt available in 8.0.12.

---

<div class="post-metadata">

**Author:** ![tohhy-pm17](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@tohhy-pm17](https://forum.inductiveautomation.com/u/tohhy-pm17)\
**Post date:** [June 25, 2021, 6:04am UTC](https://forum.inductiveautomation.com/t/perspective-auditing/30781/7 "2021-06-25T06:04:38Z")

</div>

Thanks for your post bro @richard.d.white
