How to add search filter to "Data Table from Instance Definition"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 02:34 PM
In CMS, end users could click the magnifying glass at the top of any table and set their search or filter criteria.
(eg. to filter their incidents, approval requests, or service requests)
In Service Portal, I cannot find any way to provide the same functionality to end users.
The "Data Table from Instance Definition" widget doesn't seem to have any comparable functionality such that an end user can easily filter their list.
After digging into it and opening a HI ticket, I found that the "Data Table from URL Definition" does allow user filtering.
Data Table from URL definition widget
It doesn't give you the ability to search via columns in the header, but it does allow the full filtering capability available in the main SN UI.
I was able to enable the filtering feature for the "Data Table from Instance Definition" via the following steps:
1. Clone the widget "Data Table from Instance Definition"
2. Add the below line "enable_filter: true" to the parameters passed to the widget-data-table in the server code:
var widgetParams = {
table: data.table,
fields: data.field_list,
o: data.o,
d: data.d,
filter: data.filter,
window_size: data.window_size,
view: 'sp',
title: options.title,
show_breadcrumbs: true,
enable_filter: true
};
3. Update your instance references to target your custom "Data Table from Instance Definition"
The result is the below:
The one caveat I have found is that for some reason, default filters passed via the instance definition do cause the list to be filtered correctly, however if the user tries to edit their filters, the default filter does not appear in the condition editor as an active condition.
To work around this, I am just ensuring that any reference to this page (the page containing the widget) also includes the same parameters in the URL that were passed via the instance definition.
?id=approvals&table=sysapproval_approver&filter=approverDYNAMICjavascript:gs.getUserID()
Why not just use the "Data Table from URL Definition" at this point instead? I suppose that would be another option. I just wasnt crazy about the idea of allowing users to try look at any table by adjusting their URL. Maybe that's paranoid of me though...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2018 09:28 AM
Can you elaborate what you mean by step #3?
I have updated the server side script as described above, but the dynamic filtering option is not available.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2018 09:39 AM
A widget can be referenced on multiple service portal pages.
When you add a widget to a page, you are adding an "instance" of the widget to the page.
Open up the service portal page that has the widget in it, and you will see there is an instance of the widget.
Update that instance to use your customized version of the widget, rather than the OOTB widget.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2018 10:51 AM
To fix the problem, go to widget "widget-filter-breadcrumbs", and add line
initialQuery: query
below line 9 in the server script, like this
if (data.enable_filter)
data.filterWidget = $sp.getWidget('sn-desktop-filter', {
table: table,
initialQuery: query
});
and you should be good