Hiding buttons in Vision

I’m pretty new to Vision and scripting. Does anyone know how to hide / disable a button during certain states? (e.g., if we’re running Step 1, I don’t want someone to be able to click “Start Step 2”).

You would bind the Visible property to something.

You can also bind to the enabled property which might be better.
Expression binding on enabled:


It is less confusing to the user to disable instead of making invisible. Do make sure your button code is placed in the actionPerformed event, not one of the click events.


Hi Team,
I am having a main Window, in this I have One update button to update the data in table.
I want to visible the update button for Admin but need to hide for other user when they logged in.
I have written update query on Update button.

I want to perform this on same single button.

after launching

I tried Security option and hasRole("Administrator") .

I want table data to dispalyed, but update button should disable.

please suggest code.

What bindings do you have on the table?

I am updating the table data using update button, on this I have written script and calling updated named query.

Below is the script : on this same button how to disable update button for other than admin. but I want all users can see the data .If other than admin logins update button should disable
if system.gui.confirm("Are you sure you want to update the selected row?", "Are You Sure?", 0):

# Grab the values from the text fields.

machineid = event.source.parent.getComponent('machineid').text
machinename = event.source.parent.getComponent('Machine name').text
scrap = event.source.parent.getComponent('Scrap').text
totaldelay = event.source.parent.getComponent('Toal Delay').text

# Grab the selected row.
selRow = event.source.parent.getComponent('Power Table').selectedRow
# Using the selected row, we need to get the value of the id column in that row.
MachineID = event.source.parent.getComponent('Power Table').data.getValueAt(selRow, "MachineID")
# Run a query that will update the values of the row matching the id.
system.db.runNamedQuery("UPDATE_BUTTON_SCRAP", {"MachineName" :machinename, "Scarp_Last_Hour" :scrap , "TotalDelay" :totaldelay, "MachineID" :machineid})
# Refresh the table to immediately show the updated data.
system.db.refresh(event.source.parent.getComponent('Power Table'), "data")

If the user said no to the update.

system.gui.messageBox("User canceled the update.", "Update Canceled")

If you put your script in the button's actionPerformed event, disabling the button will prevent the script from happening.

I am not getting the solution.

I want to use same update window for both admin login and operator login.
If admin logins all button should visible(means can able to update)
if operator logins same window should open but button should be disable or hide.

The hasRole expression function should work. Please show:

  • Bindings you have on the button (visible and/or enable properties).
  • Security settings for the button (At this point, I don't know which you are trying to use).
  • Is the project set up to the same user source as the roles you are tryong to use?
  • Is spelling correct? Or any leading or trailing whitespace in the role names?

Thank you, hiding is working perfect with hasRole :grinning: :slight_smile: