Button’s visibility for different groups of users.

Question:

How can I change a button’s visibility according to the user logged in the application?

Solution:

To do so, just link the following condition in the button’s Visible property:

Viewer.User = "username"

 

In this case, if the condition is True, the button is visible. Otherwise, it becomes invisible.

Attached to this article is a sample application, developed with E3 version 3.2, that illustrates the procedure above. It works like this:

  1. There are two users registered in the domain: user A (password: A), and user B (password: B).
  2. When you run the application, a login button is displayed on the main screen. Click this button log in the application with one of these users.
  3. According to the user logged in, the button will or will not be displayed on screen.
********

Question:

How can I have a button be visible only for users in the Administrator group?

Solution:

To do so, one possibility is to create and internal tag in the Viewer, set its Value property as Boolean, and add the following script to Viewer’s OnLogin event:

'Tag's Value is 1 if user belong to Admin group
Item("Name of internal tag created in Viewer").Value = IsUserMemberOfGroup("Administrator")

 

Then, link the internal tag to the button’s Visible property. This will cause the button to become visible when tag value is 1 (i.e., user belongs to Administrator group), and invisible otherwise.

Attachments:

ScreenObjectsVisible.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 5 / 5. Count: 1

Leave a Reply

Your email address will not be published.Required fields are marked *