# Switch Users in Vision

**URL:** <https://forum.inductiveautomation.com/t/switch-users-in-vision/96087>\
**Category:** Ignition\
**Tags:** vision, scripting\
**Created:** [September 17, 2024, 7:51pm UTC](https://forum.inductiveautomation.com/t/switch-users-in-vision/96087 "2024-09-17T19:51:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elmer\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@Elmer\_Sanchez](https://forum.inductiveautomation.com/u/Elmer_Sanchez)\
**Post date:** [September 17, 2024, 7:51pm UTC](https://forum.inductiveautomation.com/t/switch-users-in-vision/96087/1 "2024-09-17T19:51:32Z")

</div>

Hello,

I am needing assistance on how to use "System.security.Switchuser" function. I am having no luck on how to switch users within a client. I've used the example in the manual but get an error. " Error executing script for event: propertyChange on component: Password.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [September 17, 2024, 7:58pm UTC](https://forum.inductiveautomation.com/t/switch-users-in-vision/96087/2 "2024-09-17T19:58:15Z")

</div>

We are going to need to see your script and then the error in it's entirety.

Use the ``` to post your script and the exception so it'll read properly.

---

<div class="post-metadata">

**Author:** ![Elmer\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@Elmer\_Sanchez](https://forum.inductiveautomation.com/u/Elmer_Sanchez)\
**Post date:** [September 18, 2024, 12:50pm UTC](https://forum.inductiveautomation.com/t/switch-users-in-vision/96087/3 "2024-09-18T12:50:00Z")

</div>

The script on action event for the button is:

```python
# Pull the username and password from the input components
uname = event.source.parent.getComponent("Username").text
pwd = event.source.parent.getComponent("Password").text
  
# Call switchUser. The event object is passed to this
# function so that if the username and password work,
# this window will be closed before the switch occurs.
success= system.security.switchUser(uname,pwd)
  
# If the login didn't work, give input focus back to the
# username component, so that the user can try again
if not success:
   event.source.parent.getComponent("Username").requestFocusInWindow()

```

The error is:

Traceback (most recent call last):  
File "event:actionPerformed", line 2, in   
AttributeError: '[com.inductiveautomation.factorypmi.application.com](http://com.inductiveautomation.factorypmi.application.com)' object has no attribute 'text'

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 18, 2024, 1:17pm UTC](https://forum.inductiveautomation.com/t/switch-users-in-vision/96087/4 "2024-09-18T13:17:53Z")

</div>

Nothing pops out by looking at it. Did you try using the property browser to get to the text properties of each component?

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

---

<div class="post-metadata">

**Author:** ![Elmer\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@Elmer\_Sanchez](https://forum.inductiveautomation.com/u/Elmer_Sanchez)\
**Post date:** [September 18, 2024, 1:27pm UTC](https://forum.inductiveautomation.com/t/switch-users-in-vision/96087/5 "2024-09-18T13:27:47Z")

</div>

So, I did end up doing that and got a longer path and the error went away and now it works! Thank you! Follow up question to this. How would you "echo char" the characters in the password text field to cover up the password and close the pop up screen after a successful login?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 18, 2024, 1:48pm UTC](https://forum.inductiveautomation.com/t/switch-users-in-vision/96087/6 "2024-09-18T13:48:58Z")

</div>

Not completely sure I understand. Are you not using a password field?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/3769e4a861f41230bbbd9bd3c009336f8306fb2e.png)

---

<div class="post-metadata">

**Author:** ![Elmer\_Sanchez](https://avatars.discourse-cdn.com/v4/letter/e/c89c15/32.png) [@Elmer\_Sanchez](https://forum.inductiveautomation.com/u/Elmer_Sanchez)\
**Post date:** [September 18, 2024, 2:13pm UTC](https://forum.inductiveautomation.com/t/switch-users-in-vision/96087/7 "2024-09-18T14:13:04Z")

</div>

Didn't see that component and that was way easier than I thought haha. Thank you
