Monday, 14 March 2011

Service Manager Custom Task to Launch SQL Report

A while ago I posed a question on the Service Manager forums about having a console task that would launch a SQL Report and pass it a parameter.
The reason behind this is that I wanted to make it as easy as possible for our analysts to be able to print a “Receipt” without having to remember asset numbers or navigate through the console to the reports node.
Travis Wright came back with a couple of answers:
1) Console task which passes the parameter value on the query string to the SRS web UI.
2) Console task which passes the parameter value to the report viewer form in SCSM console.

I’d briefly looked at suggestion 1, but taken it no further, but while suggestion 2 is my preferred method I needed to move this along quicker so I took another look at suggestion 1.
As Travis said, creating a console task to spawn Internet Explorer to the SSRS url is very easy.
First go to the Library node of the console and click Tasks

Then click Create Task

Fill in the task name and description
 Then click the “…” button next to Target Class and select the class you want this task to appear on.
 In this example I’m going to use the Windows Computer class.

Fill in the path to the command as:
C:\Program Files\Internet Explorer\iexplore.exe  (Change to the x86 program files if you want the 32-bit IE)

Then comes the URL to the SSRS server and the property to pass from the SCSM console.
Let’s break the following URL down:

·         This is the base URL to the SQL Reporting Server: http://SSRS_SERVERNAME/LIVE_Reports/Pages/ReportViewer.aspx
·         This is the path to the report you want to display:
·         This is the command to render the report:
·         This is the command to pass a parameter to the report, in this case the “ComputerName” parameter:

This is where you use the “Insert Property” button in the create task wizard and select the property you require.
In this example I used the NetBIOS computer name property which returned:

And finally add &rc:Parameters=false to the end of the command line to hide the parameter bar by default.
Review the summary and save finish the task wizard.
When you go to a view showing the class you targeted in the wizard, you should now see a new console task.

When you select an item and click the task, Internet Explorer should spawn, take you directly to the report and pass the report the parameter (NetBIOS Computer name in this example) and render the report ready for printing.

No comments: