- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2020 08:46 AM
Hi Snow Community,
Is it possible to use the widget Data Table widget from instance with a recordwatcher ?
I'm actually inserting record though a button on our portal, and my list below display my data, but I have to refresh my page to see what I inserted
I cloned the widget Data Table From Instance and I added this into the client script but its not working
spUtil.recordWatch($scope, "u_item_list", "", function(name, data) {
spUtil.update($scope);
});
Any one has a clue ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2020 04:25 AM
Your code seems correct. You may have to also take into account of the filters and order because they may need to be reset. I've attached my update set also if you can't get it working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2020 10:15 AM
The easiest solution would be to refresh the page.
If you do not want to go along that, I would recommend using angulars $broadcast and $on functions to update the list. Record watcher, in this case, would be overkill due to it always watching for changes. When using $broadcast you isolate your API calls to only when an event has happened.
To achieve this you will need to broadcast the event has happened:
$scope.server.update().then(function(){
$rootScope.$broadcast('sn-record-updated')
})
And then Listen with the following:
$scope.$on('sn-record-updated', function() {
spUtil.update($scope);
})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2020 01:41 AM
Hello LJ Hazel,
Thanks for your answer, I tried few version but I wasn't able to make it works,
Here my code :
Widget #1: (data table from instance client script)
function ($scope, spUtil, $location, spAriaFocusManager, $rootScope) {
$scope.$on('sn-record-updated', function() {
spUtil.update($scope);
});
$scope.$on('data_table.click', function(e, parms){
var p = $scope.data.page_id || 'form';
var s = {id: p, table: parms.table, sys_id: parms.sys_id, view: 'sp'};
var newURL = $location.search(s);
spAriaFocusManager.navigateToLink(newURL.url());
});
}
Widget #2 : (were I insert my record on server side)
function($scope, spUtil, $rootScope) {
var c = this;
c.uiAction = function(action) {
c.data.action = action;
c.server.update().then(function() {
$rootScope.$broadcast('sn-record-updated');
c.data.action = undefined;
})
}
}
But nothing happen, did I miss something ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2020 04:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2020 07:05 AM
Thanks you so much for your help ! It works !
Its because i cloned the data table from instance, and not data table directly I think, anyway it works thanks !