- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2018 09:50 AM
Business:
My business is I have one button in "data table from instance definition" widget named as "Active" button, Whenever I click that button I need to show only active records, I am a beginner of service portal, So only I starting with basic works.
Issue:
Whenever I try to pass the filter condition via client side, That time the widget showing info message like"No records in".
Use the following image for reference:
I have found the root cause of the issue, But I still cannot able to find the solution for this.
The root cause of the issue:
The embedded widget is not refreshing. (Here embedded widget is "widget-data-table")
data.dataTableWidget = $sp.getWidget('widget-data-table', widgetParams);
The embedded widget is only working one time. If you try and refresh the widget via the server it returns an empty data model.
The following scripts for your reference:
Client script:
var c = this;
$scope.activeRecord = function(){
c.data.filter ="active=true"
c.server.update();
spUtil.get("widget-data-table", answer).then(function(response) {
c.data.dataTableWidget = response;
});
}
Server script:
data.filter = input.filter;
data.table_label = gr.getLabel();
var widgetParams = {
table: data.table,
fields: data.field_list,
o: data.o,
d: data.d,
filter: data.filter,
window_size: data.window_size,
view: options.view,
title: options.title,
show_breadcrumbs: false,
show_keywords: true
};
data.dataTableWidget = $sp.getWidget("widget-data-table", widgetParams);
})();
Html:
<sp-widget ng-if="data.dataTableWidget" widget="data.dataTableWidget"></sp-widget>
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2018 06:21 AM
The following script is worked as I expected. We need to call the server side object into the client side using var params = $scope.data.widgetParams; [data.widgetParams], We can get the embedded widget using spUtill.get and we can send the response to that specific widget.
Client script:
var c = this;
$scope.activeRecord = function(){
var params = $scope.data.widgetParams;
params.filter = "active=true";
spUtil.get('data_table_1',params).then(function(response){
$scope.data.dataTableWidget = response;
})
}
Server script:
var widgetParams;
data.table_label = gr.getLabel();
data.widgetParams = {
table: data.table,
fields: data.field_list,
o: data.o,
d: data.d,
filter: data.filter,
window_size: data.window_size,
view: options.view,
title: options.title,
show_breadcrumbs: false
};
//gs.addInfoMessage("Filters"+data.widgetParams.filter);
//data.dataTableWidget = $sp.getWidget("data_table_1", widgetParams);
data.dataTableWidget = $sp.getWidget('data_table_1', data.widgetParams);
//data.dataTableWidget = $sp.getWidget('data_table_1', {filter: widgetParams.filter});
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2020 10:35 AM
THIS should be the answer. This simple 1-liner works wonders! Thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2020 12:24 AM
Thank you so much for sharing your solution! It's working like a charm! Awesome!
Alternative solution also working:
$scope.$broadcast('data_table.setFilter', myEncodedQuery);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2021 02:13 PM
Can you please post a full client and server side code? I am not getting as to why we need code on both side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2021 02:15 PM
Can you please elaborate by providing full client and server side code? As per documentation we can use either server side or client side code then why we need both?