How to create a drill-down Web part

book

Article ID: 180948

calendar_today

Updated On:

Products

Management Platform (Formerly known as Notification Server)

Issue/Introduction

 

Resolution

Question
How do I create a drill-down Web part?

Answer

When a Web part is configured to get results from a report, the Web part runs the report and interprets the data through a control called WebPartReportView.aspx. This control takes a report GUID as an argument and returns the results of the report as an HTML table to be displayed in the Web part.

Most reports in the Altiris database return data as text and values. When these reports are interpreted through the WebPartReportView.aspx control, the resulting HTML table contains the text and values from the report. This allows you to view data in a Web part, but it does not make the Web part interactive.

A more interesting Web part would give you the ability to create a drill-down report much like you can already do within the Altiris Console. This is possible within a Web part. It simply takes some manipulation of the data in the underlying report.  Remember, the WebPartReportView.aspx control renders the results as HTML. Therefore, it is possible to embed HTML in the report results. This HTML can be a link to another report in the Altiris database (or any other link available through HTTP).

The following examples show you how to create a report and a Web part that supports the HTML drill down (with parameter passing). This example will show you how to look at the latest packages available in the Altiris database.

  1. Create the report that will be accessed through the Web part. This would be equivalent to the second level of a drill-down report in Altiris reporting terminology.
    1. Create a new report and give it a name.
    2. Click on the Enter SQL Directly option in the Report Wizard.
    3. Type in (or copy) the following SQL:

      SELECT * FROM SWDPackage WHERE _Latest=%Current%

    4. Click Finish.
    5. Edit the report and add a new parameter called Current that has type Basic.
    6. Apply the changes to save them.
  2. Create a new report that will be used by the Web part to display a link as HTML.
    1. Create a new report and give it a name.
    2. Click on the Enter SQL Directly option in the Report Wizard.
    3. Type in (or copy) the following SQL:

      SELECT _Latest AS 'Latest Value',
      '<A HREF="/Altiris/NS/Admin/Reports/report_summary.aspx?Guid=<GUID_OF_REPORT_CREATED_IN_STEP_1>&Current=' + cast(_Latest as nvarchar(100)) + '" TARGET="_blank">' + cast(Count(*) as nvarchar(100)) + '</A>' as 'Currency Count'
      FROM SWDPackage
      GROUP BY _Latest

    4. Click Finish.

A sample XML report has been attached to this article for reference and import.  There are a few items to note in the SQL of step 2c:

  1. Make sure the <GUID_OF_REPORT_CREATED_IN_STEP_1> is replaced with a valid GUID from the Altiris database.
  2. The text value aliased as "Currency Count" is a simple HTML A tag reference. A valid HTML A tag should be created and displayed in the column when the report is run.
  3. All concatenated values must be cast as nvarchar to support the creation of the text HTML A tag. This is the purpose of the cast statements in the SQL.
  4. The TARGET="_blank" attribute of the HTML A tag will cause the drill-down report to be created in a new window

Configure a Web part to use the report in Step 2 once both reports have been created. When the preview is shown in the Web part page, you should see a clickable link. Clicking on this link should bring up the drill-down report in a new window with the correct parameter passed.

It is important to be able to find the GUID for any report or item that was created. There are a few ways to get the GUID of an item. Here are two easy ways to accomplish this:

  1. Right-click on the item in the Altiris Console and select Properties from the context sensitive menu. This will cause a new window to open. The GUID is listed under the tab marked General.
  2. Right-click on the item in the Altiris Console and select View as XML from the context sensitive menu. This will cause a new window to open. The GUID of the report can be found at the top of the XML document or in the URL bar of the Web browser.

Similar methodologies can be used to link Web parts to the Resource Manager, as an example. Simply replace the HREF statement with the link to the Resource Manager instead of the report_summary page in the HREF:

/Altiris/Resource/ResourceManagerConsole.aspx?ItemGuid=<ITEM_GUID>

Attachments

SWD Package Summary.xml get_app