How to hide widgets if no data in table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2018 03:28 PM
Hello,
I have a requirement to hide the Project Status Risk, Project Status Issues, and Project Status Changes widgets from the OOB Project Status Report page if the respective tables are empty (EX: for a project with no risks, hide the Project Status Risk widget from the status report). I have not been able to figure out how to get those widgets to hide from coding in the server/client scripts. I wanted to query the "Risk" table for any risks that match the project on the status report, but no luck there.
Does anyone have any ideas how to accomplish this requirement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 10:35 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 10:41 AM
Try this. For the panel bar, I hav added the script marked in bold. If this doesn't work, can you post the server script as well.
<div ng-if="data.count>0">
<div class="panel panel-default b">
<div class="panel-heading">
<div class="hidden-xs row">
<span class="col-sm-3 panel-heading-col">
<div class="panel-title">${Status History}</div>
</span>
<span ng-repeat="date in data.dates | limitTo: 9 track by $index" class="col-sm-3 status-hr panel-title" ng-bind="date"></span>
</div>
</div>
<div class="hidden-xs panel-body" ng-repeat="category in c.data.categories">
<div class="row service">
<div class="col-sm-3 bold status-header">
<h5 ng-bind="::category.label"></h5>
</div>
<!--
<div ng-repeat="n in [0,1,2,3,4,5,6,7,8,9,10] track by $index" class="col-sm-1 status-column">
<span class="fa" ng-class="c.data.statuses[category.name][n].icon">
<span class="tooltiptext" ng-if="c.data.statuses[category.name][n].comment && n<=5" ng-bind-html="c.data.statuses[category.name][n].comment"></span>
<span class="tooltiptext margin_override" ng-if="c.data.statuses[category.name][n].comment && n>5" ng-bind-html="c.data.statuses[category.name][n].comment"></span>
</span>
</div>
-->
<div ng-repeat="status in c.data.statuses[category.name] | limitTo: 9 track by $index" class="col-sm-1 status-column">
<span class="icon" ng-class="status.icon" tooltip-class="comment-tooltip" tooltip-append-to-body="true" uib-tooltip-html="'{{status.comment}}'" role="tooltip">
</span>
</div>
</div>
</div>
</div>
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 11:06 AM
I tried making the change you documented, but no luck. Here's the server script. Do I have to make another css variable for .panel-default that sets background-color=grey;?
(function() {
// populate the 'data' object
// e.g., data.table = $sp.getValue('table');
function getIcon(value) {
if ( value == 'green' )
return 'icon-success-circle';
else if ( value == 'yellow' )
return 'icon-not-started-circle';
else
return 'icon-warning-circle';
}
data.count = 0;
var s = new PmProjectStatusReport();
data.limit = 11;
var endDate = $sp.getParameter('sysparm_status_date') || new GlideDate().getDisplayValue();
var statuses = s.getStatuses($sp.getParameter('sysparm_sys_id'), endDate, data.limit);
data.categories = [];
data.categories.push({label: gs.getMessage('Overall'), name: 'overall'});
data.categories.push({label: gs.getMessage('Schedule'), name: 'schedule'});
data.categories.push({label: gs.getMessage('Cost'), name: 'cost'});
data.categories.push({label: gs.getMessage('Resources'), name: 'resources'});
data.categories.push({label: gs.getMessage('Scope'), name: 'scope'});
data.statuses = {};
data.statuses.overall = [];
data.statuses.cost = [];
data.statuses.schedule = [];
data.statuses.scope = [];
data.statuses.resources = [];
data.dates = [];
for ( var i=0; i < statuses.length; i++ ) {
data.statuses.overall.push({icon: getIcon(statuses[i].overall), comment: statuses[i].comments});
data.statuses.cost.push({icon: getIcon(statuses[i].cost), comment: statuses[i].cost_comments});
data.statuses.resources.push({icon: getIcon(statuses[i].resources), comment: statuses[i].resources_comments});
data.statuses.schedule.push({icon: getIcon(statuses[i].schedule), comment: statuses[i].schedule_comments});
data.statuses.scope.push({icon: getIcon(statuses[i].scope), comment: statuses[i].scope_comments});
data.dates.push(statuses[i].date);
}
//gs.info("cost_comment: " + (new JSON()).encode(data.statuses.cost));
})();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 11:14 AM
It should work. Can you add this and see what it prints for data.count
<div ng-if="data.count>0">
data.count is {{data.count}}
<div class="panel panel-danger">
<div class="panel-heading">
<div class="hidden-xs row">
<span class="col-sm-3 panel-heading-col">
<div class="panel-title">${Status History}</div>
</span>
<span ng-repeat="date in data.dates | limitTo: 9 track by $index" class="col-sm-3 status-hr panel-title" ng-bind="date"></span>
</div>
</div>
<div class="hidden-xs panel-body" ng-repeat="category in c.data.categories">
<div class="row service">
<div class="col-sm-3 bold status-header">
<h5 ng-bind="::category.label"></h5>
</div>
<!--
<div ng-repeat="n in [0,1,2,3,4,5,6,7,8,9,10] track by $index" class="col-sm-1 status-column">
<span class="fa" ng-class="c.data.statuses[category.name][n].icon">
<span class="tooltiptext" ng-if="c.data.statuses[category.name][n].comment && n<=5" ng-bind-html="c.data.statuses[category.name][n].comment"></span>
<span class="tooltiptext margin_override" ng-if="c.data.statuses[category.name][n].comment && n>5" ng-bind-html="c.data.statuses[category.name][n].comment"></span>
</span>
</div>
-->
<div ng-repeat="status in c.data.statuses[category.name] | limitTo: 9 track by $index" class="col-sm-1 status-column">
<span class="icon" ng-class="status.icon" tooltip-class="comment-tooltip" tooltip-append-to-body="true" uib-tooltip-html="'{{status.comment}}'" role="tooltip">
</span>
</div>
</div>
</div>
</div>
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 11:25 AM
It doesn't seem to be printing anything in the widget. I noticed that I copied/pasted the wrong server script/html code, but it shouldn't matter as I want to add that gray header bar to all of the widgets on the page. Could it be due to the <span> tag for the column headers? Here's a screenshot of what I have so far: