Data Table Widget

sgmartin
Kilo Guru

Using the Data Table widget in the Service Portal that comes with Helsinki.   Cloned it so that I could make it work for me.   I added the table name (change_request) and added the fields I wanted to see.   That however doesn't seem to be what that field means when I edit the widget.   The widget defaults to 4 fields (Number,Category,Short Description and Approval).   I did not select all of these and actually added a couple others I wanted to see but they don't show.   I love the look of the table that it presents, but it's just not acting the way I expected.   What am I missing about customizing/configuring a widget?

48 REPLIES 48

Rama Chandra D
Kilo Guru

Hey Stanley.



Yes, the fields option for Data Table widget doesn't seem to work. It doesn't populate the values of the 'Field' from the widget configuration page to the server script. I suggest you to use 'Data Table from Instance Definition' and then add the required fields. This worked for me. The 'fields' variable in 'widgetParams' passes the user field values to the while fetching 'Data Table' widget.



Regards,


Darshak


boosted
Kilo Guru

it looks like this is fixed in Helsinki Patch 8.


anindya_11
Giga Contributor

HI Stanley,



I am facing bit of a same problem. In my case only the label of "opened_at"   is not showing while data is coming fine for end user, admin and ITIL can see that.   I have checked there is no ACL on this. PFB image.


Hey folks,



There is a simple fix to this widget, rather than having static values set for the fields.



I noticed the mapping from the data object on the server script is different from the client script.  



So on the client script I did the following:



At the beginning put the bolded statement after event names:


var eventNames = {


  click: 'data_table.click',


  setFilter: 'data_table.setFilter',


  setKeywords: 'data_table.setKeywords'


  };



  //added code


  var title = $scope.options.title;


  var fields = $scope.options.field_list;



Then there is a point where it says "Make Widget Async."   I changed the information a little to this:


// Makes Widget Async


  title = $scope.options.title;


  $scope.data = $scope.options;


  $scope.data.fields = $scope.options.field_list;


  $scope.loadingData = true;


  $scope.server.update().then(function() {


                $scope.loadingData = false;


                $scope.data.title = title;


                $scope.data.fields = fields;


                initRecordWatcher($scope.data.table, $scope.data.filter);


  });



This fixes the title issue, and the field list issue. Technically, i don't think you need to have the title = statement, but i left that there because currently everything works.



-Travis


Hello,



We have a requirement to display incident/RITM short description instead of survey description (asmt_assessment_instance) in the widget.



find_real_file.png



I have cloned the OOB data table widget and added the below code to fetch the actual incident short description. Issue is i am able to get the short description but unable to set it in the description field (refer above screenshot) :



var z = new GlideRecord(data.table);


z.addQuery("user", gs.getUserID());


z.addQuery("metric_type.active", true);


z.addQuery("metric_type.publish_state", "published");


z.addQuery("preview", false);


z.addEncodedQuery("stateINready,wip");


z.addEncodedQuery("sys_created_onONLast 30 days@javascript:gs.daysAgoStart(30)@javascript:gs.daysAgoEnd(0)");


//z.orderByDesc('sys_updated_on');


z.orderByDesc('state');


z.orderBy('due_date');


z.orderBy('sys_created_on');


z.setLimit(max);


z.query();


while (z.next()) {


if(z.trigger_table){


var tr = new GlideRecord(z.trigger_table);


if(tr.get(z.trigger_id)){


z.metric_type.description=tr.short_description;



//console.log("desc" +z.metric_type.description);                       } }


}



Any help is greatly appreciated !!!@Stanley Martin @niamccash