How to show only specific fields in table filter on Service Portal for an end user (customer)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2020 11:13 AM
Hello,
I've a requirement to show only few fields for the end user in table filter on service portal. Can we achieve this?
Thanks in advance,
Akhil

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2020 01:03 PM
Hi Akhil,
Implement with caution, the solution has DOM manipulation and it is highly likely to break in future version
Below is working for paris version of servicenow
Additional Client controller:
You need to inject the service snCustomEvent like below
snCustomEvent.on('snfilter:activated', startRemoving);
function startRemoving(){
setTimeout(function(){
removeFiltersColumms(document.getElementsByClassName("field-list-button"));
}, 3000);
function removeFiltersColumms(elementbyclass){
var validArray =$scope.data.validColumms;
var validArray1 = validArray.split(",");
var arrayObj = [];
var fieldLists = angular.element(elementbyclass).scope().comparison.baseFields;
var count = Object.keys(fieldLists).length;
for(var i=0; i<count; i++)
{
var fieldname = Object.keys(fieldLists)[i];
var columnname =fieldLists[fieldname]["name"];
if(validArray1.indexOf(columnname) < 0 && columnname != "123TEXTQUERY321"){
arrayObj.push(columnname);
}
}
for( var z= 0; z< arrayObj.length; z++){
delete fieldLists[arrayObj[z]];
}
observermethod();
}
function observermethod(){
var target = document.getElementsByClassName("compounds")[0];
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
var el = document.getElementsByClassName("field-list-button");
for(var i = 0; i< el.length; i++){
removeFiltersColumms(el[i]);
}
});
});
var config = {childList: true, subtree: true }
observer.observe(target, config);
}
Server side code:
data.validColumms = "active,name";// coma separated column name or $sp.getListColumns(data.table, "your view here");
Screenshot
Attached the widget so you can play around with it 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 12:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2021 02:54 AM
I have similar requirement its any other way to achieve this without DOM manipulation. Please assist on that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2021 04:59 AM
Hi,
You can restrict read access to those fields for end user.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2021 06:07 AM
Hi Asha,
Thanks for the heads up. Looking forward to hearing from you! .