How to write a script for a button which open popup window(to enter password) and I need to valid the password and conduct the button action?
Vision or Perspective?
Sounds like you may want system.security.validateUser - Ignition User Manual 8.1 - Ignition Documentation
Have a popup to get the username / password from the user and this function will check that it's a valid user against a specified user source.
If it is Perspective, maybe it is no a good idea to just set lock the navigation button. If your screen has URL somebody can just type in URL directly. If you do not use URL, other project cannot use navigation button to access your screen, it would be good for integration. You can lock the screen or objects.
You can enable/disable objects by binding it to user name or user group.
How can I pass, the password and UN from popup to script?
You can use the authentication challenge.
This will create a popup for the user to login, then fire a callback with the result for you to do something. You can send a payload of data through with it for context as well.
what is callback? How can I get the feedback of the opened window(login) that created from AthenticationChallenge ?
The session event onAuthenticationChallengeCompleted looks like it is fired when the challenge is complete. Perspective Session Event Scripts - Ignition User Manual 8.1 - Ignition Documentation
@ignitionSL the manual explains how it works.
As mentioned, there is an event listed in the Perspective session events that will be fired when the user completes the authentication challenge.
You can use the parameters passed into that method to determine what to do and you can pass some state in the payload when you call the challenge if you need to.
For example you can check that the credentials used for the challenge belonged to a certain role, like that the user is an administrator.
def onAuthChallengeCompleted(session, payload, result): myData = payload.get('myData', None) if result.isSuccess() and myData: context = result.getAsSuccess().getContext() user = context.user if 'Administrators' in user.roles: #do something