Hide Columns from the Filter list - Implementation

Ariel Aharon
Giga Guru

Hello everyone,

 

I stumbled upon a community article to hide some columns from filter list

This article helps / explains, using a secript, to hide the column only from the filter list but keep it in the list view and it's given a UI script there.

 

I'm unsure how to implement it or if thats solution is still valid, could anyone clarify on how to execute it? or on how to achieve that.

3 REPLIES 3

Community Alums
Not applicable

Hi @Ariel Aharon ,

 

You can try using a UI Script -

Can you please try this code once-

addLoadEvent(function() {
    var tableName = g_list.getTableName();
    var columnsToHide = ['column_to_hide1', 'column_to_hide2']; // Replace with your columns
    if (tableName === 'your_table_name') { // Replace with your table name
        setTimeout(function() {
            columnsToHide.forEach(function(column) {
                g_filter.removeChoice(column);
            });
        }, 500); // Delay to ensure filter is ready
    }
});

 

SanjayG_0-1725366011580.png

 

 

Hey,

 

I tried this script, and it basically messed up UI functionallity (in console it showed g_list and / or fields variable is not defined) and no context menu was showing, as well as UI actions we're not responding.

 

I reverted changes using Background Script turning that UI Script off.

 

Is there an official doc on how to create load / change / submit *UI Scripts*?

Community Alums
Not applicable

Hi @Ariel Aharon ,

The issue seems to be the timing of the list load.

Ensure the script runs after the UI elements are loaded.

 

Not sure of any other approach for this.

Take a look into this thread- 

https://www.servicenow.com/community/developer-forum/ui-script-with-onload-and-onchange-client-scrip...