Service Portal Data Table Widget Customization

Community Alums
Not applicable

I've been working on a space-saving customization to the "Data Table from Instance Definition" widget. 

Basically, I want users to be able to click a button and be able to choose which list they see, as well as be able to click an item on the list and have it load on the form widget on the same page.
I have that part working, using $broadcast to send events and pass information between the various widgets, see below:

find_real_file.png

find_real_file.png

find_real_file.png

find_real_file.png

 

What I haven't been able to figure out is how to get the Filter to respond. I've been through all the nested widgets, replaced them with custom ones, and passed every variable i can think of to every place i can think of, and no luck. The best I can figure, the filter widget (which is another embedded widget) isn't being reset when everything else is. Either that or theirs some piece of data I'm not passing.

Anyone have any ideas?

I really wish I could tag people, because I'd love to ask Nathan Firth or Chuck Tomasi about this one.

16 REPLIES 16

nathanfirth
Tera Guru

We have a similar widget that we use, it's a configurable widget that takes properties to define the tabs and filters, and then embeds the data table to render the list. You should not have to clone any of the OOB widgets to accomplish this.

Try something like this... in your controller:

var options = {
    filter: "opened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe^active=true",
    page: "ticket",
    table: "incident",
    view: "sp"
};

spUtil.get('widget-data-table', options).then(function(response) {
    $scope.widget = response;
});

and then in the HTML embed it as usual:

<sp-widget widget="widget"></sp-widget>

I haven't tested this, but it should work.

This is what our widget looks like. It has options for tables, filters, columns, etc. so that we can use it against any set of tables.

find_real_file.png

Hope that helps,

-----------------
Nathan Firth
Founder and ServiceNow Architect
NewRocket, Inc.
nathan.firth@newrocket.com
http://serviceportal.io
http://newrocket.com

Community Alums
Not applicable

Nathan,

 

Thanks! That part is working. It's the embedded filter widget that isn't. When the page loads, the list is drawn from the incident table, and the fields to choose in the filter load fine:

find_real_file.png

 

But when  I switch it to the Requested Item table, it won't load anything but "keywords":

find_real_file.png 

I think I've found the code responsible in the Server Script for the data table widget:

find_real_file.png

 

I have set the values for data.table, and data.filter, but I can't seem to get the widget to actually use them. I've dumped $scope to console both when it's working and not, and compared the structure of the relevant parts, and they seem identical (except for table names, of course) so I'm not sure what I'm doing wrong.

 

Hi @nathanfirth would you mind sharing the code for that widget? We have the same requirement as what your screenshot shows.

Hi @nathanfirth can you share how you made the Active/Inactive buttons inside the Incidents tab? From what I see on your screenshot, you got different tabs and inside them you can set the filters rendered on the table with those buttons?