Client Event Script

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 error2

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.

2 Likes

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

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

2 Likes

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).

Hi

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

thanks