# Who pushed the button?

**URL:** <https://forum.inductiveautomation.com/t/who-pushed-the-button/63246>\
**Category:** Ignition\
**Created:** [August 21, 2022, 4:18pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246 "2022-08-21T16:18:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [August 21, 2022, 4:18pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/1 "2022-08-21T16:18:39Z")

</div>

So I did a search and couldn’t find anything related.  
I want to know who pushed my button… but seriously…  
I have a reset button to try and track belt life on a piece of equipment. We want to be able to track who pushed it.  
I have client event script that works fine but the issue is that it is randomly pulling a user who is logged in not the user who actually pushed the button. How do I work around this?  
This is what I have…

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

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 21, 2022, 4:43pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/2 "2022-08-21T16:43:10Z")

</div>

You need to somehow have the user log in again to use the button.

> ... but the issue is that it is randomly pulling a user who is logged in not the user who actually pushed the button.

That's not random. That's, as far as the system knows, the current user.

One way would be to have a popup that offers the user a choice. "Username password required to perform this action. [Proceed] [Cancel]". Pressing proceed would log the current user out and present the login dialog. I don't use _Vision_ anymore so I'm not sure of the details.

---

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [August 21, 2022, 4:52pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/3 "2022-08-21T16:52:09Z")

</div>

I hear what you are saying but the log ins are all different people already logged into the project on their respective computers. So I need to identify which user who is logged in already was the one who pushed the button.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [August 21, 2022, 5:04pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/4 "2022-08-21T17:04:50Z")

</div>

I don’t get why you can’t use the built in audit log?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 21, 2022, 5:26pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/5 "2022-08-21T17:26:11Z")

</div>

> [@jason.schwenk](#):
>
> ... but the log ins are all different people already logged into the project on their respective computers.

It's not clear from your question whether each user has a unique login or they are sharing a single login. If they are unique does `system.security.getUsername` not return that unique name?

---

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [August 21, 2022, 5:54pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/6 "2022-08-21T17:54:08Z")

</div>

Each person has a unique log in. But yet when I run that script it pulls a random person from the list of people who are logged in

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [August 21, 2022, 6:17pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/7 "2022-08-21T18:17:26Z")

</div>

Call the script that records who pushed the button from the button push event (not a tag change event).

---

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [August 21, 2022, 6:59pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/8 "2022-08-21T18:59:56Z")

</div>

Sounds good but I cant seem to find where that would be located.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 21, 2022, 7:20pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/9 "2022-08-21T19:20:29Z")

</div>

Right-click | Scripting …

 ![Vision button event](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/e/dea7a3505a19c218ed0cf127b9fd935bf7f26411.png)

---

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [August 21, 2022, 7:28pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/10 "2022-08-21T19:28:26Z")

</div>

I’ve tried that but there isnt any access to any properties that will give me which user pressed the button though

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/e/4ecd0dcf14705724bf21e93cedfede04243ecdb5.png)

---

<div class="post-metadata">

**Author:** ![jason.schwenk](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jason.schwenk/32/18822_2.png) [@jason.schwenk](https://forum.inductiveautomation.com/u/jason.schwenk)\
**Post date:** [August 21, 2022, 7:37pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/11 "2022-08-21T19:37:24Z")

</div>

It works!! I guess I didnt try to use the security.getUsername in the component scripting window  
Thank everyone!

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fb86a5882877466f249638ad84ab4cc9d078e9ed.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 21, 2022, 7:37pm UTC](https://forum.inductiveautomation.com/t/who-pushed-the-button/63246/12 "2022-08-21T19:37:37Z")

</div>

You were searching for a Python scripting function in the button’s properties. It won’t be there.  
Just add `= system.security.getUsername()` where your cursor is.
