Hide Columns from the Filter list

art_anderson2
Tera Expert

In various message boards and forums I find that folks have been asking this for at least a decade. Most of the solutions provided have not actually answered the request.

 

We need to be able to hide a column from the List Filter -- and

We need that column still available in the List View -- and

We need that column still available in the user forms -- and

We need that column still available in user reports

 

Thus

A read ACL to hide/restrict the field will hide/restrict it from all the items

An add-list ACL prevents it from being added to the list view but it still exists in the filter

 

Two options came to mind while I have been trying to resolve this

  • In the dictionary, it would be nice if there was an attribute such as "no_list_filter"
  • And/or, it would be nice if there was a slush bucket in list control indicate by view which columns to hide

Has anyone been able to resolve this issue in a manner that does not incur a ton of technical debt?

I have posted this to SN via HI as a question to suggest an enhancement request for ServiceNow to address it, seems like a lot of folks want this.

 

One workaround that I am looking at is creating a database view that only contains the columns I want to include, this is a little restrictive and I'd rather not kludge it. I would still like users to be able to have list view of columns I don't want filtered, but at least I can limit it somewhat.

 

Since it's been at least a decade where folks have asked for this, it would be nice if it did not take another decade to get it.

 

Thanks,

Art

2 REPLIES 2

Ahana 01
Tera Expert


To hide columns from the filter list in ServiceNow, you can follow these steps:

1. Navigate to the list where you want to hide columns from the filter list.
2. Right-click on the column header and select "Configure > List Layout".
3. In the slushbucket, move the columns you want to hide from the "Selected" side to the "Available" side.
4. Click on "Save".

Please note that this will also remove the column from the list view. If you want to hide the column only from the filter list but keep it in the list view, you will need to use a UI Script or a UI Policy. Here is a sample UI Script:

javascript
function onLoad() {
var tableName = g_list.getTableName();
if (tableName == 'incident') {
var ga = new GlideAjax('FilterColumnsAjax');
ga.addParam('sysparm_name', 'getColumns');
ga.addParam('sysparm_table_name', tableName);
ga.getXMLAnswer(handleResponse);
}
}

function handleResponse(answer) {
var columns = answer.evalJSON(true);
for (var i = 0; i < columns.length; i++) {
if (columns[i] == 'column_to_hide') {
g_filter.removeChoice('column_to_hide');
}
}
}


Replace 'incident' with your table name and 'column_to_hide' with the column you want to hide. This script will remove the specified column from the filter list when the list is loaded.


nowKB.com

For a good and optimistic result, and solving ServiceNow-related issues please visit this website.https://nowkb.com/home
Kindly mark correct and helpful if applicable

sumanta pal
Kilo Guru


As a ServiceNow expert, I understand your concern. Unfortunately, as of now, ServiceNow does not provide a direct way to hide a column from the list filter while keeping it available in the list view, user forms, and user reports. However, I can suggest a workaround that might help you achieve your goal:

1. Create a new field in the table that mirrors the data of the field you want to hide from the list filter. This can be done using a business rule or a script include that copies the data from the original field to the new field whenever a record is created or updated.

2. Hide the original field from the list filter by setting up a read ACL that restricts access to the field. This will prevent the field from appearing in the list filter.

3. In the list view, user forms, and user reports, use the new field instead of the original field. Since the new field mirrors the data of the original field, it should serve the same purpose.

4. To keep the data in the new field up-to-date, make sure to update it whenever the original field is updated. This can be done using a business rule or a script include.

Please note that this workaround might not be suitable for all use cases and might require additional testing and validation. It's also important to keep in mind that this workaround might increase the complexity of your ServiceNow instance and might require additional maintenance.

Here is a sample code for a business rule that copies the data from the original field to the new field:

javascript
(function executeRule(current, previous /*null when async*/) {
current.new_field = current.original_field;
})(current, previous);


And here is a sample code for a script include that does the same:

javascript
var CopyField = Class.create();
CopyField.prototype = {
initialize: function() {
},

copyField: function(record) {
record.new_field = record.original_field;
record.update();
},

type: 'CopyField'
};


To use the script include, you would need to create a business rule or a scheduled job that calls the copyField method for each record in the table.

For asking ServiceNow-related questions try this :

For a better and more optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.

Please visit : https://nowkb.com/home
Our Website :https://nowkb.com/home
Link - https://nowgpt.ai/