The purpose of this article is to demonstrate the use of global parameters in report building. Global parameters can be used to allow a report to query the address bar for values instead of prompting a user prior to running the report. I have found this helpful on a number of occasions where I have wanted to have a program or ASP page display an Altiris report based on certain criteria without the having to prompt the user.
Creating your Report:
Begin by creating a new report. In this example I will create a simple report that pulls information based on a list of serial numbers that will be pulled from the address bar. The SQL for our report will be:
Select [Serial Number],
[Asset Type],
Status,
Model
From vAsset
Where [Serial Number] in (%SERIALLIST%)
(%SERIALLIST% is the global parameter that we will populate when the report is run.)
Next, create a new Global Parameter. This is done from the main edit page by clicking the New Parameter button:
The parameter will have the following attributes:
Name: SERIALLIST
Parameter Type: Basic
Value Type: None
Leave everything else as default, making sure that the Prompt User checkbox is not checked. We don’t want the report to require user interaction. You can change the name of your variable if you wish, but it is very important that you select “None” as the value type. If this is not set to “None”, Altiris will place quotes around the value that is passed in and that will break your SQL query.
The report is now complete. Next we will discuss how to run it.
Running your Report:
Usually to run a report, the user is required to click on the “Run this report” button:
In order to make this report run without that sort of interaction, we need to get the URL that should be placed in the address bar to make our report run automatically.
To get the URL, run your report in a new window by clicking the "run this report in a new window" at the top:
(Note, it will return an error because we have not provided it with the SERIALLIST parameter that it is looking for. This is OK.) Once the report has run and returned the error, copy the URL from the address bar at the top of the browser. It will look something like this:
http://its-altirisrpt/Altiris/NS/Admin/Reports/report_summary.aspx?Guid=76b95778-2d56-47ec-8417-67687b9ebb65
This is the URL to your report. The next step is to incorporate the SERIALLIST global parameter that we set up into the URL. Parameters are appended to the end of the URL by adding a “&” then the parameter, followed by an “=” and then the values you want to pass in. So in our case, the URL could look something like this:
http://its-altirisrpt/Altiris/NS/Admin/Reports/report_summary.aspx?Guid=76b95778-2d56-47ec-8417-67687b9ebb65&SERIALLIST='7sf9p81'
Notice that the value you pass in has to be in single quotes so it is SQL friendly.
Placing this in my address bar pulls up the following results:
You may have noticed that in our SQL we used “Where [Serial Number] in” in our query. This allows us to feed multiple serial numbers in all at the same time. Here is an example of what the URL could look like to pull back results on multiple machines at once:
http://its-altirisrpt/Altiris/NS/Admin/Reports/report_summary.aspx?Guid=76b95778-2d56-47ec-8417-67687b9ebb65&SERIALLIST='7sf9p81','c0b00b1','4k88v51'
All we are really doing is giving that SERIALLIST parameter a comma separated list of values. The results come back like this:
That is all there is to it. Now external applications and web pages can run customized reports by passing values in through the address bar!
I hope this has been helpful.