Refresh table data when clicking on Refresh button on Data Table widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 12:37 PM
Hello All,
I have a Custom data table widget, which is displaying a list of Cases.
I have added a refresh button to just refresh the widget data and not the whole page.
Using this Refresh button, I'm getting the updated data in the server side but the HTML part is not getting updated with the new data.
For example:
I have updated the short description of CS0000002 from backend. When clicked on 'Refresh' button, I'm getting the updated value in console, but the table is not getting updated.
HTML:
<button type= "button" ng-click="c.refreshData()">${Refresh}</button>
<tbody>
<tr ng-repeat="item in data.list track by item.sys_id">
<td role="{{$first ? 'rowheader' : 'cell'}}" class="pointer sp-list-cell" ng-class="{selected: item.selected}" ng-click="go(item.targetTable, item)" ng-repeat="field in ::data.fields_array" data-field="{{::field}}" data-th="{{::data.column_labels[field]}}"><a href="javascript:void(0)" ng-if="$first" aria-label="${Open record}: {{::item[field].display_value}}">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</a><span ng-if="!$first">{{::item[field].display_value | limitTo : item[field].limit}}{{::item[field].display_value.length > item[field].limit ? '...' : ''}}</span>
</td>
</tr>
</tbody>
Client Controller:
c.refreshData = function() {
$timeout(function() {
spUtil.update($scope);
}, 10);
}
Please Help.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2024 06:41 PM
it's the first time I see someone asking for a manual refresh button in the Service Portal. There are basic approaches to let ServiceNow refresh the data inside a widget automatically! Watch the following video for more information: https://www.youtube.com/watch?v=Eg7l15v-nd0
Maik