Updating "My Lists" widget on CSP portal to display Cases, Requests, and Incidents.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2022 12:18 PM
I am on the /CSP portal looking at the "My Lists" widget and I was wondering if anyone has changed the options on the left side of this widget to include Incidents and actual Requests (ITSM). Our users can create Cases, Incidents, and Requests and I would like this filter to give them the option to all of those things. Thanks in advance for any helpful guidance. I intend to also do this same thing on the /SP portal for our internal users.
- Labels:
-
Customer Service Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 09:03 AM
Did you ever find the solution for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2023 01:29 AM
Hi together,
although you might have found a solution for your issues I would like to depict the way I solved this since it caused me some trouble and research too. A post that brought me to the right track was this
So let's break it down a bit.
1. Get to the menu script: The menu item configuration for "My lists" can be found if you navigate through Classic UI: All > Service Portal > Portals (Choose your portal)
The "My lists" menu item is linked inside the menu widget:
Once you open the menu item, navigate down to the related list "Menu items", where you will find at least one "My Lists" entry (there are multiple entries that will show up for different roles, be careful with rmoving them, I tried it...)
Select the "csm_my_lists" page entry to get one more step deeper into the rabbit hole. Once you navigated to the "csm_my_lists" page, scroll down to a section named "Page Content" and select "My list filters" next to Instace: My Lists
You could - obviously - just as well go to the All > Service Portal > Widgets module and look for your My list filters widget but I think it's woth tracking its path.
2. Find the right entrance into the script: Anyway now we have arrived at the place where the magic happens. Scroll down to the "Server script" section and you will see the script that loads the list which represents the menu filters:
(function() {
data.list = [];
data.selectedFilter = $sp.getParameter('sel');
data.list = new sn_customerservice.CSMServiceManagementUtil().getMyListsMenu();
data.pageContentLoadedMsg = gs.getMessage('{0} content loaded');
})();
Fair enough. As you see the script calls the method "getMyListsMenu()" inside the "CSNServiceManagementUtil()" class. That class can be found when you look up the "sys_scripe_include.list" in the All navigation search bar. You will find a library that is responsible for all different service management integration functions inside CSM. You will also see the "getMyListsMenu" method that returns an array of objects:
getMyListsMenu: function() {
var list = [];
var myListFilters = [gs.getMessage("All Cases"), gs.getMessage("Action Needed"), gs.getMessage("My Cases")];
var query = [null, "stateIN6,18", "initiated_as_request=false"];
var filters = ['all', 'act_needed', 'my_issues'];
if (GlidePluginManager.isActive(CSMServiceManagementUtil.REQUEST_PLUGIN_ID)) {
// if request plugin is active, then add My requests
myListFilters.push(gs.getMessage("My Requests"));
query.push("initiated_as_request=true");
filters.push("my_req");
}
// [...]
return list;
}
This script is, for good reason, not mutable (at least not without brute force). But we can make use of the fact that we know what the list array might contain.
If you have a look at the debugger, you see four objects containing the list query and label configurations:
3. Remove unused items: With our new knowledge we can now manipulate the list to our needs. You can do this quick and dirty by inserting all your code in the "My list filter" widget's server script field. I chose to add my own Class to the 'sys_script_include' section to set up a library with different methods to manipulate the list. Provide a class name ServiceNow will provide you with a Class corpus in turn where you can add your methods like so:
removeDefaultRequestFilters: function(lists) {
var removable_filters = ['my_issues','my_req'];
var valid_items = [];
for (var counter = 0; counter < lists.length; counter++) {
if(removable_filters.indexOf(lists[counter].selectedFilter) === -1) {
valid_items.push(lists[counter]);
}
}
return valid_items;
},
You see what I did is to pass the list item as a parameter and return a cleansed item containing not the items I want.
4. Add desired list filters:
This one is a bit more work but simple nontheless (once you know how to do it as usual in SN):
First things first - if you want your list displayed with a name, you must add one (plus translation if desired) in All > System UI > Messages:
You can now utilize that message. I added methods for each list I want to add to the lists list:
addQueryItem: {
incidentCases: function(lists) {
var queryParams = {};
queryParams.table = "sn_customerservice_incident_case";
queryParams.view = "csp";
queryParams.myListFilter = gs.getMessage("My Incident Cases");
lists.push(queryParams);
return lists;
},
}
This might not be the most beautiful solution possible I know. However, it works. What's more, there is one thing I have not found out yet, that is marking the list as "active", i.e. set the right css class when it is selected. Hope this brings you to the right track.
I will keep you updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2023 01:50 AM
One quick additional info, which is important, however:
Provide page context: ServiceNow will not be able to open the listed records unless you provide a target page id:
queryParams.targetPageId = "csm_ticket";
Set selected filter: If I had read Mahesh Kumar3's post thoroughly, I would have seen that you need to provide a selectedFilter param which will then allow SN to mark the selected filter:
queryParams.selectedFilter = "my_incident_cases";
Et voilá - Everything is just splendid: