The next wizard screen lets you define the action syntax to return to the client application and that's subsequently used to initiate the action. In this example, you need to format the action syntax as a URL. This wizard screen contains a button that invokes the MDX Builder so that you can incorporate data from the cube into the action syntax. Because this action is available when a user clicks a particular course number, the resulting URL must incorporate the course number to build the link to the course syllabus. Thus, you need to choose the dimension and use the CurrentMember function and the Name property to return the course number clicked.
"http://www.quilogy.com/courses/"
+ [Course].CurrentMember.Name +
".htm"
You can then give the action a name, and it becomes available in the Actions folder.
Actions for Developers
After adding the actions to the cube, the developer side of you has two primary tasks: First, you must build an interface so that a user can recognize when an action is available, and second, you must let the user invoke the action. For this example, I modified the earlier ASPADOComplex.asp page to be action aware. First, the ASP page must query the cube to determine whether a particular member has actions associated with it. You can use the ADO Connection object's OpenSchema method to perform this function. This method accepts a constant that determines the type of rowset to return and an array that specifies the restrictions the server uses to build the rowset. Analysis Services extends the OLE DB specification by adding the constant adSchemaActions to it to pass as the first argument to OpenSchema. The returned rowset (called an MDSCHEMA_ACTIONS rowset) contains one row for each action and includes the columns that Table 2 shows. The second argument to OpenSchema is an array that defines a set of restrictions to place on the columns in Table 2. Table 2 also shows the order of the restrictions array and whether the argument is optional.
Next, you need to create a UI cue so that the user can recognize that an action is available. To create the cue, I added the server-side DisplayURLAction procedure and associated constants to the ASP page, as Listing 2, page 42, shows. Note that the procedure first executes OpenSchema, as callout A in Listing 2 shows, using the Array function to pass the adSchemaActions constant and the set of restrictions. In this case, the array specifies the Enrollment cube (the third argument); only URL action types (fifth argument); the member to query for actions, as passed to the DisplayURLAction procedure (sixth argument); and the action's scope (seventh argument)in this case, actions at the member level. Note that you can use an empty string (" ") to pass optional arguments.
If OpenSchema finds actions, the DisplayURLAction procedure relies on Dynamic HTML (DHTML) to build an image tag, as callout B in Listing 2 shows. The image tag displays a visual UI cue (an image) and a table (initially hidden) that contains one row for each URL action defined for the member, as callout C in Listing 2 shows. In addition, callout B in Listing 2 shows that the image tag's onClick attribute is set to invoke a client-side script procedure called ShowActions. ShowActions, which Listing 3, page 42, shows, is passed the table's element ID so that it can toggle the display attribute between block and none. Thus, when the user clicks the image, ShowActions displays or hides the member's list of actions, according to the setting. The class attribute of the table is set to clsActionMenu, which sets the cursor type to hand to provide a visual cue that users can click for actions as callout C in Listing 2 shows. Each row in the table contains a column that displays the URL action returned from the rowset, as callout C in Listing 2 shows.
The table's CONTENT column contains the URL that the administrator defined and that was dynamically built when the Cube Editor generated the action. The ACTION_NAME column contains the action's name, in this case Syllabus. The column's onClick attribute is set at callout C in Listing 2 to run the client-side InvokeURLAction procedure. The InvokeURLAction procedure uses the Document Object Model (DOM) window object's Open method to open the URL in a separate window when the user clicks the action.
The only remaining task is to position the call to DisplayURLAction. The ASPADOComplex.asp page contains loops that iterate the axes that the MDX query produced in the cellset. As the captions for the row and column headers are printed to the ASPADOComplex.asp page, the following statement calls the DisplayURLAction procedure with the member's UniqueName:
Call DisplayURLAction(cst.Axes(1).Positions(j)
.Members(h).UniqueName)
If DisplayURLAction finds actions, the procedure adds their image to the HTML stream and sends the stream to the client. The resulting page shows the results of an MDX query that uses the Course- Num member with the actions activated for course 2072, as Figure 5 shows. Note that the icon directly to the right of each course number is the visual cue that URL actions exist for this member.
A New Dimension
By adding support for drillthrough and actions to OLAP client applications, you can provide the user with a whole new dimension of information. Analysis Services reduces by an order of magnitude the amount of developer effort that was previously required to provide these options with OLAP Services. Take a look at how you can integrate drillthrough and actions into your Web applications. If you're one of the many developers who requested that Microsoft add these abilities, I won't have to make that suggestion twice.