| name | reporting-dashboards |
| description | Build ServiceNow reports (list/bar/pie/line/pivot/single-score) on sys_report, sys_dashboard layouts with widget placement, scheduled report delivery, and drill-down configuration. |
| license | Apache-2.0 |
| compatibility | Designed for Snow-Code and ServiceNow development |
| metadata | {"author":"serac","version":"1.0.0","category":"servicenow"} |
| tools | ["snow_create_report","snow_create_dashboard","snow_schedule_report_delivery","snow_query_table"] |
Reporting & Dashboards for ServiceNow
ServiceNow provides comprehensive reporting capabilities for data visualization and business intelligence.
Report Types
| Type | Use Case | Example |
|---|
| List | Tabular data | Incident list |
| Bar | Category comparison | Incidents by priority |
| Pie/Donut | Distribution | Tickets by category |
| Line/Area | Trends over time | Weekly ticket volume |
| Pivot Table | Multi-dimensional | Priority x Category |
| Single Score | KPI value | Open P1 count |
| Gauge | Progress/threshold | SLA compliance |
Creating Reports
List Report (ES5)
var report = new GlideRecord("sys_report")
report.initialize()
report.setValue("title", "Open High Priority Incidents")
report.setValue("table", "incident")
report.setValue("type", "list")
report.setValue("filter", "active=true^priority<=2")
report.setValue("field", "number,short_description,priority,state,assigned_to,opened_at")
report.setValue("orderby", "priority")
report.setValue("order", "ASC")
report.setValue("group", "assignment_group")
report.setValue("user", gs.getUserID())
report.setValue("roles", "itil")
report.insert()
Bar Chart Report (ES5)
var barReport = new GlideRecord("sys_report")
barReport.initialize()
barReport.setValue("title", "Incidents by Priority")
barReport.setValue("table", "incident")
barReport.setValue("type", "bar")
barReport.setValue("aggregate", "COUNT")
barReport.setValue("group", "priority")
barReport.setValue("filter", "active=true")
barReport.setValue("show_data_label", true)
barReport.setValue("show_legend", true)
barReport.setValue("chart_color", "blue")
barReport.insert()
Trend Report (ES5)
var trendReport = new GlideRecord("sys_report")
trendReport.initialize()
trendReport.setValue("title", "Incident Volume - Last 30 Days")
trendReport.setValue("table", "incident")
trendReport.setValue("type", "line")
trendReport.setValue("trend", "opened_at")
trendReport.setValue("trend_interval", "day")
trendReport.setValue("aggregate", "COUNT")
var thirtyDaysAgo = new GlideDateTime()
thirtyDaysAgo.addDaysLocalTime(-30)
trendReport.setValue("filter", "opened_at>=" + thirtyDaysAgo.getValue())
trendReport.setValue("stack", "priority")
trendReport.insert()
Pivot Table (ES5)
var pivotReport = new GlideRecord("sys_report")
pivotReport.initialize()
pivotReport.setValue("title", "Incidents: Priority vs Category")
pivotReport.setValue("table", "incident")
pivotReport.setValue("type", "pivot")
pivotReport.setValue("group", "priority")
pivotReport.setValue("stack", "category")
pivotReport.setValue("aggregate", "COUNT")
pivotReport.setValue("filter", "active=true")
pivotReport.setValue("show_row_total", true)
pivotReport.setValue("show_column_total", true)
pivotReport.insert()
Dashboards
Creating Dashboard (ES5)
var dashboard = new GlideRecord("sys_dashboard")
dashboard.initialize()
dashboard.setValue("name", "IT Service Desk Dashboard")
dashboard.setValue("description", "Key metrics for service desk operations")
dashboard.setValue("layout", "3")
dashboard.setValue("view_as", "desktop")
dashboard.setValue("roles", "itil")
var dashboardSysId = dashboard.insert()
Adding Widgets to Dashboard (ES5)
function addReportToDashboard(dashboardId, reportId, row, column, width, height) {
var widget = new GlideRecord("sys_dashboard_widget")
widget.initialize()
widget.setValue("dashboard", dashboardId)
widget.setValue("report", reportId)
widget.setValue("row", row)
widget.setValue("column", column)
widget.setValue("width", width || 1)
widget.setValue("height", height || 1)
return widget.insert()
}
addReportToDashboard(dashboardSysId, openIncidentsReport, 0, 0, 1, 1)
addReportToDashboard(dashboardSysId, avgResolutionReport, 0, 1, 1, 1)
addReportToDashboard(dashboardSysId, slaComplianceReport, 0, 2, 1, 1)
addReportToDashboard(dashboardSysId, trendReport, 1, 0, 3, 2)
addReportToDashboard(dashboardSysId, priorityPieChart, 3, 0, 1, 2)
addReportToDashboard(dashboardSysId, categoryBarChart, 3, 1, 2, 2)
Scheduled Reports
Create Scheduled Report (ES5)
var schedule = new GlideRecord("sys_report_schedule")
schedule.initialize()
schedule.setValue("report", reportSysId)
schedule.setValue("name", "Weekly Incident Summary")
schedule.setValue("recipients", "it-managers@company.com")
schedule.setValue("recipient_users", managersSysIds)
schedule.setValue("recipient_groups", itManagersGroup)
schedule.setValue("run", "weekly")
schedule.setValue("day", "monday")
schedule.setValue("time", "08:00:00")
schedule.setValue("format", "pdf")
schedule.setValue("subject", "Weekly IT Incident Summary")
schedule.setValue("message", "Please find attached the weekly incident summary report.")
schedule.setValue("active", true)
schedule.insert()
Advanced Reporting
Report with Formula Field (ES5)
var report = new GlideRecord("sys_report")
report.initialize()
report.setValue("title", "SLA Breach Analysis")
report.setValue("table", "task_sla")
report.setValue("type", "bar")
report.setValue("aggregate", "SUM")
report.setValue("field", "has_breached")
report.setValue("formula", "CASE WHEN {has_breached} = 1 THEN 1 ELSE 0 END")
report.setValue("group", "sla.name")
report.insert()
Drill-Down Report (ES5)
var summaryReport = new GlideRecord("sys_report")
summaryReport.initialize()
summaryReport.setValue("title", "Incidents by Assignment Group")
summaryReport.setValue("table", "incident")
summaryReport.setValue("type", "bar")
summaryReport.setValue("aggregate", "COUNT")
summaryReport.setValue("group", "assignment_group")
summaryReport.setValue("is_drillable", true)
summaryReport.setValue("drill_down_report", detailReportSysId)
summaryReport.insert()
Export & Integration
Export Report Data (ES5)
function exportReportToCSV(reportSysId) {
var report = new GlideRecord("sys_report")
if (!report.get(reportSysId)) return null
var ga = new GlideAggregate(report.getValue("table"))
var filter = report.getValue("filter")
if (filter) {
ga.addEncodedQuery(filter)
}
var groupField = report.getValue("group")
if (groupField) {
ga.addAggregate("COUNT")
ga.groupBy(groupField)
}
ga.query()
var results = []
while (ga.next()) {
results.push({
group: ga.getValue(groupField),
count: ga.getAggregate("COUNT"),
})
}
return results
}
REST API for Reports
MCP Tool Integration
Available Reporting Tools
| Tool | Purpose |
|---|
snow_create_report | Create report |
snow_create_dashboard | Create dashboard |
snow_pa_create (action='scheduled_report') | Schedule delivery |
snow_pa_discover (action='reporting_tables') | Find available tables |
snow_pa_discover (action='report_fields') | Get field options |
snow_pa_operate (action='export_report') | Export data |
snow_pa_create (action='visualization') | Create chart |
Example Workflow
var tables = await snow_pa_discover({
action: "reporting_tables",
category: "itsm",
})
var fields = await snow_pa_discover({
action: "report_fields",
table: "incident",
})
var reportId = await snow_create_report({
title: "Incident Overview",
table: "incident",
type: "bar",
group: "priority",
aggregate: "COUNT",
filter: "active=true",
})
var dashboardId = await snow_create_dashboard({
name: "Service Desk Overview",
layout: "3-column",
})
await snow_add_dashboard_widget({
dashboard: dashboardId,
report: reportId,
row: 0,
column: 0,
})
await snow_pa_create({
action: "scheduled_report",
reportName: "Incident Overview",
schedule: "weekly",
recipients: ["managers@company.com"],
format: "PDF",
})
Best Practices
- Clear Titles - Descriptive, action-oriented names
- Appropriate Type - Match chart type to data
- Filter Wisely - Default to relevant subset
- Color Meaning - Consistent color conventions
- Mobile Friendly - Test on smaller screens
- Performance - Limit rows, use aggregations
- Access Control - Role-based visibility
- Regular Refresh - Keep data current