Answering Prompts via URL API

MicroStrategy offers a lot of built in manipulations that can be performed directly within the URL.  This can provide a lot of benefits for seamlessly linking to MicroStrategy reports from either within MicroStrategy itself or from an external system.  Today I’ll highlight the most common and useful thing you can do in the URL: answering prompts using several different methods.


The URL API may sound complicated, but its actually really simple and doesn’t require any actual programming or extra licenses.  This makes it the ideal tool to perform some neat tricks and even some basic “free” customizations.

Obtaining the Base URL
Before you can start modifying the URL for a report or document, you must first obtain it.  The easiest way to do this is to right click on the report or document in Web before you run it and choose Properties.  At the bottom of the screen is a link to the report.  Right click that and choose Copy Link.  In 9.2.1, there’s now the option to choose Show Link from the right click menu which saves you a step.

DO NOT ever take the URL out of your address bar.  This usually contains extra information that’s specific to your current session, or it’s missing crucial information that is already stored in your session.  These links will almost never work after your session has timed out, even for you.  When building static links, always be sure to get a “clean” URL using the method described above.

Answering Prompts
Once you’ve got the base URL, you can start adding/modifying it.  The most common task to perform is to automatically answer Prompts.  This is useful when linking to reports or documents from an existing report or document and you want to automatically answer some or all of the prompts based on previous knowledge, either because you know what the user clicked on or you know what the user previously answered.

There are 5 built in methods for answering prompts:

  • valuePromptAnswers
  • objectsPromptAnswers
  • elementsPromptAnswers
  • originMessageID
  • promptsAnswerXML

The ones you’ll most commonly use will be elementsPromptAnswers and valuePromptAnswers.  The other’s have their use too, and while they’ll all arrive at the same end result, there are situations where only one or some will work.

To apply a prompt answer, simply attach the following to the end of the URL:

Value Prompts
These are prompts where the user just types in a value in a text box, or chooses a Date from the date picker.  The syntax is:

&valuePromptAnswers=VALUE

The value is just the direct value that will be stored in the prompt, so if you were answering “South”:

&valuePromptAnswers=South

If you want to answer multiple prompts, such as “South” and “42”, then you just separate them with a ^.  The value prompts are answered in order based on the order the Prompts are presented, so be sure that they match up correctly:

&valuePromptAnswers=South^7

And if you’re answering a date or anything else that has special characters in it, you’ll need to encode the URL (I use this handy tool).  So to answer 8/11/2011:

&valuePromptAnswers=8%2F11%2F2011

The valuePromptAnswers macro doesn’t support the ability to pass an empty answer, so if you want to pass one you have to manually send the promptXML.  An empty value prompt works like an empty elementPrompt where you simply pass the prompt ID with no value.  You can do this with the following XML string:

<rsl><pa pt="3" pin="0" did="340788BD41D30090F7168AAC5ABFCB35" tp="10"/></rsl>

The did is the GUID of the value prompt.  Take this string over to the URL Encoder page, plug it in, and pass the result in the URL like this:

&promptsAnswerXML=%3Crsl%3E%3Cpa%20pt%3D%223%22%20pin%3D%220%22%20did%3D%22340788BD41D30090F7168AAC5ABFCB35%22%20tp%3D%2210%22%2F%3E%3C%2Frsl%3E

Element Prompts
Element Prompts are the most common prompt type.  These are the prompts that give you the list of elements from an attribute, commonly in a shopping cart style, and let you choose as many answers as you want for your filter.

To answer an Element Prompt, you need to pass the Attribute GUID.  The order doesn’t matter in that the Attributes being passed in will be matched up to the prompts looking for that Attribute as an answer.

&elementsPromptAnswers=AttributeGUID;AttributeGUID:Value

Notice that we have to pass the Attribute GUID twice, and that the first separater is a semicolon, and the second is a colon.  The first Attribute GUID tells the prompt which attribute is being passed, and therefore which prompt to answer.  The second one is part of the definition of an Attribute Element, which is made up of the pair AttributeGUID:Value.  It does look a little strange to have to pass the GUID twice, but there it is.

Update: Easy method for doing this dynamically.

To send multiple answers, just keep adding AttributeGUID:Value pairs separated by a semicolon.  For example, if you wanted to pass the values North and South:

&elementsPromptAnswers=AttributeGUID;AttributeGUID:North;AttributeGUID:South

Notice that we only have to give the initial AttributeGUID once, and then each Element answer we want to pass is the AttributeGUID:Value pair separated by a semicolon.

To answer multiple prompts:

&elementsPromptAnswers=AttributeGUIDFirst;AttributeGUIDFirst:Value,AttributeGUIDSecond;AttributeGUIDSecond:Value

For multiple answers, you just separate them with a comma.  The rules still apply that before each answer, you have to preface it with the Attribute GUID that you’ll be answering, and then the AttributeGUID:Value pairs of each element to answer after that.

Origin Message ID
As you can imagine with the above syntax, the URL can get quite long and complicated.  But if you just want to simply retain the Prompts that the user already answered and persist them for the next report, you can actually directly reference the values in the user’s session with the following:

&originMessageID={&DocumentMessageID}

As the name implies, this only works when linking from documents, but that {&DocumentMessageID} macro will resolve to a short alpha numeric string that represents the user’s session.  That information can then be pulled automatically by the next report to answer all of the prompts.  Any prompts that are not included in the previous report will be prompted on their own.  This saves a lot of trouble of juggling multiple answers or AttributeGUIDs and just handles everything for you.

It’s important to note that the this Message ID is user specific and session specific, which means it will only work in “real time” linking.  You can’t use this method to copy/paste a link to another user or use it in a subscription, whereas the links generated using valuePromptAnswers and elementsPromptAnswers could be shared.

Object Prompts
Objects Prompts are more complex by nature, and so is their URL API equivalent.  An Object Prompt allows you to choose which objects are displayed on the report, and it’s syntax looks like this:

&objectsPromptAnswers=ObjectGUID~ObjectTypeID~ObjectName

Yes those are tildas 🙂

The Object GUID is the GUID of the object you’re selecting, not the Object Prompt itself.  It could be an Attribute, Metric, Filter, or whatever object you’re prompting on.

The Object Type ID is the MicroStrategy internal value for the kind of Object we’re passing.  Attribute = 12 and Metric = 4, which are the most common, but for a complete list you can check out this TechNote.

Finally, the Object Name is whatever the name of the Object is.  Don’t forget to URL Encode it.  (This is actually optional, and omitting it looks like it doesn’t affect anything.  So if it’s giving you trouble, just drop it).

To pass multiple selections, simply separate them with a comma, just like last time.

Prompts Answer XML
This one is the least used but can really save you in a pinch.  It’s the same thing as the Document Message ID, except it stores the information directly in the URL in full XML glory (encoded of course). This makes the URL portable (share with others or use in a subscription), but it can get very, very long.  IE has a URL length limit of ~2,000 characters, you can easily hit it with just a few prompts using this method.  Firefox and Chrome don’t have that limit, but who can really tell with the speed at which browsers are releasing these days.

I’ve used this in the past a few times when needing to do some custom stuff, but it’s pretty rare.  Just know that it exists, it can be dynamically built at run time, and it can answer -ANY- prompt.  So if you can’t find satisfaction in one of the easy pre-built macros, research this one some more and you can definitely do it using this.

You may also like...