# Client Event Script

**URL:** <https://forum.inductiveautomation.com/t/client-event-script/36734>\
**Category:** Ignition\
**Created:** [July 15, 2020, 5:56pm UTC](https://forum.inductiveautomation.com/t/client-event-script/36734 "2020-07-15T17:56:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [July 15, 2020, 5:56pm UTC](https://forum.inductiveautomation.com/t/client-event-script/36734/1 "2020-07-15T17:56:32Z")

</div>

Hi

I have users and differents windows in a project.

I want to run a script (image event) when the Client is start, in my first windows is auto-login but i want to make a button no visible.

I put this in my Event Scripts but when the project is launched Ignition sends me an error.(image error and error2)

Can you help me?

Thanks

![error](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/4/340d9afe0c715339662b950cfda4674df7e359fb.png) ![error2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b4701b031a56947f1d6795566ff0c702337b458f.png)

 ![Event](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/a/5a694b44a073aeac2a54aec4bf3589afa3351e92.png)

---

<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:** [July 15, 2020, 6:04pm UTC](https://forum.inductiveautomation.com/t/client-event-script/36734/2 "2020-07-15T18:04:48Z")

</div>

You need to put this on the window open event rather than the client start.

The event object is only available for object events, ie button, window startup etc… not client startup scripts.

Alternatively you could have it set a client tag and read that client tag on your startup screen.

---

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [July 15, 2020, 7:52pm UTC](https://forum.inductiveautomation.com/t/client-event-script/36734/3 "2020-07-15T19:52:47Z")

</div>

Hi

Thanks for your help.

I put this in the script of my window and works.

if u’Administrator’ in system.security.getRoles():  
value = 1  
else:  
value = 0  
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.BUsuarios’).visible = value

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [July 16, 2020, 3:42am UTC](https://forum.inductiveautomation.com/t/client-event-script/36734/4 "2020-07-16T03:42:10Z")

</div>

The better option would be to use an expression binding on the visible property and use the expression `hasRole('Administrator') `  
Using a one-shot script for something like has its downsides

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [July 16, 2020, 9:15am UTC](https://forum.inductiveautomation.com/t/client-event-script/36734/5 "2020-07-16T09:15:26Z")

</div>

> [@nminchin](#):
>
> Using a one-shot script for something like has its downsides

Yes.

If you ever implement a feature to switch to a different user, this script will not be triggered, and the previous access rights will remain.

It's way better to use the included security features in Ignition (by right-clicking on a component, and selecting the security options).

---

<div class="post-metadata">

**Author:** ![eric.avila](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@eric.avila](https://forum.inductiveautomation.com/u/eric.avila)\
**Post date:** [July 16, 2020, 12:51pm UTC](https://forum.inductiveautomation.com/t/client-event-script/36734/6 "2020-07-16T12:51:23Z")

</div>

Hi

yes is better user "Security options " in the component and more easy.

thanks
