Skip to content

Version

Version > 2023.02

Lookup Fields: Auto Hide Button / Auto Disable Button

Perhaps you are familiar with the situation that, depending on userrights, read-only lookups are displayed that do not have a value. Nevertheless, a button is displayed next to it, although it does not open a data set, because nothing is selected yet.

The screenshot shows what I mean:

In this case, the button makes no sense, because it does not open a record when clicked anyway. Nevertheless, the button is displayed, which can be confusing for users:

Auto-Disable those buttons

If you want to keep the button but disable it, you can use the following code:

Button is disabled

1
2
// file: hooks/TABLENAME-dv.js
AppGiniHelper.DV.getField("lookup_fieldname").autoDisableButtons();

Auto-Hide those buttons

You can also hide those buttons completely

1
2
// file: hooks/TABLENAME-dv.js
AppGiniHelper.DV.getField("lookup_fieldname").autoHideButtons();

(button has been removed completely)


Tip: Multiple lookup fields

Instead of using DV.getField("fieldname") per lookup-field you can apply changes to multiple fields at once using DV.getFields(["f1", "f2", "..."]):

Example

1
2
// file: hooks/TABLENAME-dv.js
AppGiniHelper.DV.getFields(["previous_item_employee_id", "previous_item_location_id", "previous_item_node_id"]).autoDisableButtons();

See also