How to wrap script in a script include a call from a report created through the report designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 02:48 AM
Hi all,
I have created below script which reference a database view in a custom scoped app, where dt_dashboard.sysid reference the dashboard sysid. I need to populate this script (or similar) in a script include which I then call from a report created through the report designer. How to do this in the best way?
var dashboards = new GlideRecord('x_431699_dashboard_items');
dashboards.addNotNullQuery('dt_dashboard.name');
dashboards.orderBy('dt_dashboard.name');
dashboards.query();
gs.info('---> ' + dashboards.getRowCount());
var dashboardList = [];
while(dashboards.next()) {
dashboardList.push(dashboards.dt_dashboard.name.trim());
}
var arrayUtil = new ArrayUtil();
dashboardList = arrayUtil.unique(dashboardList);
gs.info('---> ' + dashboardList.length);
for (var i = 0; i < dashboardList.length; i++) {
gs.info('---> ' + dashboardList[i]);
}
The report on the dashboard whiteout any filtration looks like below:
The database view for dashboard is configured as below:
Basic need is, I need to query the unique values from the database view and create a report for this.
@Technomonk @Tai Vu @Ankur Bawiskar @Community Alums
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2024 02:42 AM - edited 03-12-2024 02:42 AM
Hi @Tai Vu ,
Yeah, but again, the missing information from the other columns doesn't matter. The other columns should be created in different reports. I also have though about the group by in list view which could essential resolve the requirement, just doesn't think it's the most pretty solution - Hence, looking for a more nice and clean look.
The basic idea is, if I select a dashboard in a interactive filter (above example IT Manager), you will only see the dashboard in on report, only see widgets associated to that dashboard in another report, only see Formula indicators associated in a third report etc.
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2024 02:22 AM
Hi @AndersBGS
If the other columns aren't necessary, we could consider building the report directly on the Dashboard [pa_dashboards] table.
We fetch the dashboard sys_id from the database view and then use it to filter the report results. Below is a snippet of how I implemented from my end.
var DashboardItemScriptInclude = Class.create();
DashboardItemScriptInclude.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUniqueDashboardNames: function() {
var dashboardList = [];
var dashboards = new GlideRecord('x_431699_dashboard_items');
dashboards.addNotNullQuery('dt_dashboard');
dashboards.orderBy('dt_dashboard');
dashboards.query();
while (dashboards.next()) {
dashboardList.push(dashboards.dt_dashboard.sys_id.trim());
}
var arrayUtil = new ArrayUtil();
dashboardList = arrayUtil.unique(dashboardList);
return dashboardList;
},
type: 'DashboardItemScriptInclude'
});
Cheers,
Tai Vu