Defaulting Element Selectors Using URL API

I’ve previously written about using the URL API to answer prompts of different types, but one feature that has been missing is the ability to default selectors using this method. Being able to do so would open up some really cool use cases, such as linking between dashboards or linking from a subscribed email to a dashboard while keeping the context for the user.

Well, I stumbled across a really good tech note that describes how this feature was added to 9.2.1. I was able to get it to work (with one unfortunate side effect I’m still ironing out).

This method isn’t exactly for the feint of heart. It feels more like a hack than an actual supported feature, but we’ll take what we can get I guess.

Step 1 – Get the Base LinkTo start, get the base link to your document that contains the selector you want to control. You can do this by right clicking on the report in Web, choosing Get Link, and copying the URL from the text box.

Step 2 – Get the ID of the Target SelectorThis part might be a little tricky. The Selector ID is going to be 3 characters, starting with a letter, and ending with 2 numbers, ie, W64. To get it, you have to run your document in Interactive mode and View Source in your web browser. It’ll be a little difficult to find, you’re looking for <select id=”W64″… though your ID will surely be different. The best way to find it is to use the Firebug plugin for Firefox, or Chrome’s Inspect Element utility. Right click on the selector in question, inspect it, and it should highlight the relevant code in the HTML.

There are two pieces of information you need to extract in this manor:

– Selector ID – as mentioned above, it’ll be in the format W64, or equivelant.– Element ID – it’ll start with the letter h, followed by your element and then the Attribute GUID, ie, h2;8D679D3711D3E4981000E787EC6DE8A4 would pass the value 2.

Step 3 – Craft the URLThe URL you’ll need to craft will take on this format:

An interesting thing going on here is that we’re actually passing two events (evt) to the page. I’ve personally never encountered this before, but MicroStrategy handles it by declaring the &evtorder to determine which order to process the events. I couldn’t find any documentation on event 2048084 as it’s mysteriously missing from the events.xml file on Web. I assume it’s related to selectors because of the context we’re working in. In any case, you don’t have to modify any of the non-Red fields in your link.

IssuesThis worked really well for me except for one issue I haven’t resolved yet. The document I was linking to was running in express mode (&currentViewMedia=1), but despite specifying that view mode, adding the new tags to default the selector switched the view to Interactive mode. I couldn’t find a way to overcome this and currently have a case open with Technical Support. I’ll come back and update once that’s resolved.

The source for this article is this tech note on the MicroStrategy Knowledge Base. For more information and some nice screenshots, check it out.