# Hiding a component based on username

**URL:** <https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354>\
**Category:** Ignition\
**Created:** [February 5, 2019, 4:32pm UTC](https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354 "2019-02-05T16:32:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![damzagar](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@damzagar](https://forum.inductiveautomation.com/u/damzagar)\
**Post date:** [February 5, 2019, 4:32pm UTC](https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354/1 "2019-02-05T16:32:12Z")

</div>

I have a client script which checks the logged in user and opens a window if the result is false.

name = system.security.getUsername()  
if name != ‘test’ :  
system.nav.openWindow(“Main Windows/Test”)

Next thing I want to do is check if the result is true and if it is, hide a date component on that window (Root Container.Date\_1.visible property).

How do I add the second part of the check to the client script? How do I combine the windows name and the root cantainer…visible property and write a 0 or false in it?

name = system.security.getUsername()  
if name != ‘test’ :  
system.nav.openWindow(“Main Windows/Test”)  
if name == ‘test’ :  
???.visible = 0

Thanks

---

<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:** [February 5, 2019, 4:42pm UTC](https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354/2 "2019-02-05T16:42:41Z")

</div>

Would an expression binding on the visible property accomplish what you want?

```auto
{[System]Client/User/Username} != 'test'

```

---

<div class="post-metadata">

**Author:** ![damzagar](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@damzagar](https://forum.inductiveautomation.com/u/damzagar)\
**Post date:** [February 5, 2019, 5:19pm UTC](https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354/3 "2019-02-05T17:19:51Z")

</div>

If it works it would indeed. I tried using system.security.getUsername() but that didn’t work in an expression. I’ll try this one tomorrow.

Is there a list where i can find all these variables? I tried searching but couldn’t find any.

And thanks!

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [February 5, 2019, 6:01pm UTC](https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354/4 "2019-02-05T18:01:22Z")

</div>

Just use the Security Settings to Hide the component. Find more information on that in the documentation.

[Component and Window Security](https://docs.inductiveautomation.com/display/DOC79/Component+and+Window+Security) Note: I am currently using 7.9 so this documentation is specific to that, newer version may have different information.

Also, in the Tag Browser there is a System folder which contains folders for different scopes and information.

There is also a Client folder which you and add tags to that become global to the project. (This is another way you can accomplish what you’re looking for)

---

<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:** [February 5, 2019, 8:21pm UTC](https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354/5 "2019-02-05T20:21:10Z")

</div>

> [@damzagar](#):
>
> Is there a list where i can find all these variables?

As @lrose notes, you can find these variables in the tag browser in the Designer:

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

---

<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:** [February 5, 2019, 8:28pm UTC](https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354/6 "2019-02-05T20:28:14Z")

</div>

> [@damzagar](#):
>
> I tried using system.security.getUsername() but that didn’t work in an expression

Yes, scripting functions don't work in expression bindings (and vice-versa). You can find all the expression functions in the [manual](https://docs.inductiveautomation.com/display/DOC79/Expression+Functions) as well as in the menu on the expression window:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/19ff9c7b50dc2b07a948368d420b39207df53224.png)

Note that you _can_ use the [runScript](https://docs.inductiveautomation.com/display/DOC79/runScript) expression to run a script in an expression binding, like this:

```auto
// Get username. Refresh every 250 ms.
runScript('system.security.getUsername()', 250)

```

---

<div class="post-metadata">

**Author:** ![damzagar](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@damzagar](https://forum.inductiveautomation.com/u/damzagar)\
**Post date:** [February 5, 2019, 8:44pm UTC](https://forum.inductiveautomation.com/t/hiding-a-component-based-on-username/22354/7 "2019-02-05T20:44:59Z")

</div>

Perfect!

That’s a lot of valuable info! I’ve only been using Ignition for 10 days now so pardon my “amateur” questions. I tend to get a lot of things done but sometimes I get stuck and this forum really helps!
