
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 11-14-2018 04:15 AM
Personalize option on service portal list view is one of the common ask from various customers. I have create a widget which adds a feature to allow end users to add or remove columns from list view on service portal.
Portal-List-Personalize
Widget to add personalize feature(gear icon) on servicenow Portal list view ( Download XML from Github)
Installation
Add below html code to your Data Widget's html
<span class="glyphicon glyphicon-cog" ng-click="c.personalize('personalize_list')" aria-hidden="true"></span>
Add below services to client controller
$rootScope, spModal, $window
Add below code to your Data Widget's client controller
$rootScope.$on('personalizationDone', function(event,data) {
$window.location.reload(); // refresh to new layout
});
c.personalize = function(widgetId, widgetInput) {
spModal.open({
title: 'Personalize List Columns',
widget: widgetId,
widgetInput: $scope.data.personalizeParms || {}
}).then(function(){
$rootScope.$emit('saveChosen');
})
}
Add below code to your Data Widget's Server Side code
function CheckPreference(table, view){
var userPref = new GlideRecord('sys_user_preference');
userPref.addQuery('name', table+'_'+view+'_list.view');
userPref.addQuery('user', gs.getUserID());
userPref.query();
if (userPref.next()) {
return userPref.value;
}
}
data.fields_array = data.fields.split(',');
Above line changes to below
data.fields_array = CheckPreference(data.table, data.view).split(',') || data.fields.split(',');
Add below code to your Data Widget's Server Side code
var personalizeObj = {};
personalizeObj.table = data.table;
personalizeObj.view = data.view;
data.personalizeParms = personalizeObj;
Import Attached UI script and Widget
- 5,114 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Amazing work
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
In my case data.view is undefined hence not working properly. Do you have any idea?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Rahul, I am unable to find the UI script attachment
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Rahul,
I am not able to find UI Script attachment
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
UI Script was not necessary. We followed the steps mentioned on the github url and got the list mechanic icon.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Rahul,
In my case, Once I click on OK button on the widget, changes are not reflected on the list.
Could you please let me know what I am missing here?
Thanks

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This is amazing, thank you so much for doing this. Much appreciated!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I was hoping that SN would have included this in its base widgets ... Any updates to this ?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Has anyone gotten this to work with Data Table from URL Definition widget?

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I was able to get this working in a scoped app, here are my notes on that:
- The actual 'personalize_list' widget has to stay in the global scope. I tried to clone that into my scope and found that it couldn't write back to the 'sys_user_preference' table when the columns were customized. The initial customization of the columns worked (which would be an insert into the sys_user_pref table), but then when I tried to change them around again, it didn't work. If you look at the "updatePreference" function in the server script on this widget, you'll see the "uprefApproval.update()" fails. To see this happen, change that line to:
if(uprefApproval.update()){
gs.info("it saved");
} else {
gs.info("did not save");
}
- Also, the OP mentioned the following line for this to work. For the scoped app, I had to change that line from this:
data.fields_array = CheckPreference(data.table, data.view).split(',') || data.fields.split(',');
...to this:
var custCols = CheckPreference(data.table, data.view);
if(custCols){
data.fields_array = CheckPreference(data.table, data.view).split(',')
} else {
data.fields.split(',');
}
because CheckPreference was coming back with nothing on initial page load (this is to be expected, no columns had been customized yet) and was throwing an error because of this. So I created a kind of "pre-check" to see if CheckPreference would return anything first.
- I also noted that if export from a list view in service portal, the export doesn't adhere to the customized columns - it just uses the "base" view columns (e.g. pre-customized).
Hope this helps! 😁
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Rahul,
Will it work Data Table from Instance Definition widget with the same code?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Has anyone gotten this solution working with Xanadu and in the CSM portal (or any other portal aside service portal)? Thanks!