MicroStrategy ONE

Retrieving Report XML in a Custom Format

Integrating MicroStrategy functionality into an external application can require you to provide MicroStrategy report XML in a custom format such as XBRL, FinXML, Accounting XML, etc. so that it can be consumed by the external application.

In this customization scenario, you extract data from MicroStrategy Web and render it in a sample custom XML format. Since different applications have different data input requirements (that is, they each specify the particular XML format which they can consume), you must modify the code sample provided for the transform in this customization scenario so that it renders report data in the particular XML format (such as XBRL, FinXML, Accounting XML, etc.) required in your environment.

It is important to note that this customization scenario is applicable only for reports that are displayed in a tabular mode and only for reports that do not have merged row headers. A report in a tabular mode is defined as a report that has only attributes in rows and only metrics in columns. Reports displayed in a non-tabular mode and reports with merged row headers do not return the correct report XML. 

The diagrams below show a tabular report displayed in MicroStrategy Web and its corresponding report data in the custom XML format produced by the code samples used in this customization scenario. The <error> node in the report XML displays "Error message" on the report if an error is thrown. In the sample tabular report shown below, there is no error and thus no error message. This scenario uses the Units Sold, Revenue by Category report in Shared Reports>MicroStrategy Platform Capabilities>MicroStrategy SDK inside of MicroStrategy Tutorial.

MicroStrategy report data rendered as a grid in MicroStrategy Web:

MicroStrategy report data rendered in a custom XML format in MicroStrategy Web:

Copy
<?xml version="1.0" encoding="utf-8" ?>
<mstr-report>
  <information>
    <report-name>Units Sold, Revenue by Category</report-name>
    <report-id>433CD21B4AD6168A2C952E985039CEE9</report-id>
    <report-desc />
    <number-of-rows>4</number-of-rows>
    <number-of-cols>2</number-of-cols>
    <message-id>8DA6A5964CF1008C9927A692EE8C94F5</message-id>
    <state-id>0</state-id>
    <block-begin>1</block-begin>
    <block-count>-1</block-count>
  </information>
  <report-data>
    <titles>
      <col index="1">Category</col>
      <col index="2">Units Sold</col>
      <col index="3">Revenue</col>
    </titles>
    <rows>
      <row index="1">
        <col index="1">Books</col>
        <col index="2">249,600</col>
        <col index="3">$4,024,235</col>
      </row>
      <row index="2">
        <col index="1">Electronics</col>
        <col index="2">170,940</col>
        <col index="3">$58,837,793</col>
      </row>
      <row index="3">
        <col index="1">Movies</col>
        <col index="2">202,954</col>
        <col index="3">$3,188,745</col>
      </row>
      <row index="4">
        <col index="1">Music</col>
        <col index="2">156,972</col>
        <col index="3">$2,315,694</col>
      </row>
    </rows>
  </report-data>
</mstr-report>

This customization can be accomplished using either of the following methods:

Deploying the plug-in provided with MicroStrategy SDK:

MicroStrategy SDK provides a plug-in (ZIP file) that can simply be extracted to the plugins folder to view the customization in MicroStrategy Web. The following steps guide you in locating the plug-in and deploying it. 

  1. Access the plug-in: JSP version or ASP .NET version

  2. Extract the plug-in to the plugins subfolder inside the MicroStrategy Web installation folder.   

  3. Launch the Task Administrator application.

    The domain where you are running the Task Administrator application and the domain of the MicroStrategy server must be the same. If the domains don't match, the browser will not allow the javascript request to go through and you will get an error. 

  4. Click the Builder tab at the top. 

  5. Select reportDataService from the Task ID drop-down menu. 

  6. Select xml from the Task Envelope drop-down menu. 

  7. Select xml [Default] from the Task Content Type drop-down menu.

  8. Enter appropriate values for the following parameters and check the Include box:

    1. server: The value should be the IP address or name of your MicroStrategy server::

      The domain where you are running the Task Administrator application and the domain of the MicroStrategy server must be the same. If the domains don't match, the browser will not allow the javascript request to go through and you will get an error.

    2. styleName: For this example, the value for this should be the CustomXMLReportStyle style that you created above.
    3. project: For this example, the value should be MicroStrategy Tutorial.
    4. userid: The value should be administrator.
    5. password: The value should be blank.
    6. reportID : For this example, the value should be 433CD21B4AD6168A2C952E985039CEE9 if you are using the Units Sold, Revenue by Category report in Shared Reports>MicroStrategy Platform Capabilities>MicroStrategy SDK inside of MicroStrategy Tutorial).

    The values for the remaining parameters can be left blank or you can add values relevant to your customization. 

  9. Click the Update URL button to generate the URL. 

  10. Click the Invoke URL button to retrieve the Task Response.

Using the Web Customization Editor to create a plug-in

MicroStrategy SDK provides a Web Customization Editor that can be used to create a customization plug-in. The following steps guide you in creating the plug-in and deploying it. 

  1. Launch the Web Customization Editor

  2. Click on MicroStrategy Web Configuration inside the Application Settings view to expand the hierarchical tree. The expanded list comprises the different settings that can be modified to perform customizations. 

  3. Right-click Styles and select Create Transform to launch the Transform Creation Wizard

  4. Click Browse... next to the Source folder text field to select the src folder and click OK

  1. Enter the following information for the rest of the text fields.

    1. Package: com.microstrategy.sdk.samples.transforms
    2. Name: CustomXMLReportTransform
    3. Transform description: This transform renders a simplified version of the report xml
    4. Superclass: com.microstrategy.web.transform.AbstractTransform
  2. Click Next.

  3. Click the radio button for Uncheck all methods

  4. Click Next.

  5. Click Finish. CustomXMLReportTransform.java opens in the editor. The sample, CustomXMLReportTransform.zip, contains the entire code for this custom transform. You can use this code in CustomXMLReportTransform.java that is open for editing. This custom transform parses the ReportBean and renders its properties in a specified XML format.

  6. Save your changes.

  7. Right-click Styles and select New Style to launch the Style Creation Wizard.

  8. Make the following entries.

    • Name: CustomXMLReportStyle
    • Description: Style: Display report in xml format
    • Transform: CustomXMLReportTransform 
  9. Click Next.

  10. Click Next

  11. Click Finish.

  12. Save your changes.

  13. Exit the Web Customization Editor.

  14. Launch the Task Administrator application.

  15. Click the Builder tab at the top.

  16. Select reportDataService from the Task ID drop-down menu.:

    This task automatically logs you out after retrieving the report XML. If you wish to keep the login session open, use thereportExecute task along with the getSessionState task.

  17. Select xml from the Task Envelope drop-down menu. 

  18. Select xml [Default] from the Task Content Type drop-down menu.

  19. Enter appropriate values for the following parameters and check the Include box:

    1. server: The value should be the IP address or name of your MicroStrategy server.:

      he domain where you are running the Task Administrator application and the domain of the MicroStrategy server must be the same. If the domains don't match, the browser will not allow the javascript request to go through and you will get an error.

    2. styleName: For this example, the value for this should be the CustomXMLReportStyle style that you created above.
    3. project: For this example, the value should be MicroStrategy Tutorial.
    4. userid: The value should be administrator.
    5. password: The value should be blank.
    6. reportID : For this example, the value should be 433CD21B4AD6168A2C952E985039CEE9 if you are using the Units Sold, Revenue by Category report in Shared Reports>MicroStrategy Platform Capabilities>MicroStrategy SDK inside of MicroStrategy Tutorial).

    The values for the remaining parameters can be left blank or you can add values relevant to your customization.

  20. Click the Update URL button to generate the URL.

  21. Click the Invoke URL button to retrieve the Task Response.
     

See Also