Thursday, June 20, 2013

Passing Prompt Answers in URL


At least couple of times in your project, you might have come across a situation where you need to share a view of your dashbaord or report, based on the prompts that you selected. Fortunately, MicroStrategy supports and provide a way to pass the prompt answers in the URL, So that you can generate the URL and share it with other or you can even use it for stress testing. 

There are few types of Prompts and the parameter for each of these are different.

Prompt Type                                      Parameter
Element list Prompt                              elementsPromptAnswers

Value Prompt                                      valuePromptAnswers

Object Prompt                                    objectsPromptAnswers


Unfortunately i did not see a method for passing  a level prompt in the URL 

Now that we know the parameter for different prompts, lets see how to pass values to these prompts.

  • elementsPromptAnswers
    • AttributeID;AttributeElementID^DisplayName is the formart
    • AttributeID;AttributeElementID^DisplayName;AttributeElementID^DisplayName  --. when you have multiple answer for a prompt. 
    • AttributeID;AttributeElementID^DisplayName;AttributeElementID^DisplayName,AttributeID;AttributeElementID^DisplayName when you have multiple prompts.
  • valuePromptAnswers
    •  Unlike the element prompt, here there is no option to refer to the attribute. Hence the order in which you give the prompt answers will impact the results. If one of the answer is empty, you need to properly delimit that.
    • user carat "^" for delimitation. eg: Books^2013^India . If you dont answer 2013, the format will be Books^^India
  • objectsPromptAnswers
    • The name in the below format is optinal, but without that you will not be able to refer to the prompt in the document. Also since the prompt answers do not have identifiers to map then to prompts, the order in which the prompt is answered is important. 
    • objectID~type~name is the format 
    • objectID1b~type1b~name1b^objectID2a~type2a~name2a  -> multiple objects prompts answered.
    • objectID1a~type1a~name1a%1BobjectID1b~type1b~name1b  -> passing multiple objects in one prompt.
You can find the objectID either from the metadata or more easily from the desktop. Right click and check the property.

Now lets look at constructing the URL.

For a Dashboard, URL is

http://Localhost:8080/MicroStrategy/servlet/mstrWeb?

evt=2048001
&src=mstrWeb.2048001
&documentID=
&ViewMedia=2
&elementsPromptAnswers=

For a Report, URL is
http://localhost:8080/MicroStrategy/servlet/mstrWeb?

&src=mstrWeb.4001
&evt=4001
&reportID=
&elementsPromptAnswers=

Notice the highlighted changes in event number and document / report ID.

Lets look at an example. I have a document with a report, and it has all the below types of prompts. It has object prompt, element prompt. 
Objects          -> attr - category / brand / call center
                      -> metric - profit / revenue
elmemt list      -> limited on the year

How do I add the elments and objects to the url  ? We can follow the method described above. But it becomes tedious and error prone when the number of elements and objects increase. What is the best way to create the url in this case ?

Fortunately, MSTR also supports passing prompts as XML. Now how do we generate an XML. It is Quiet easy.  Just place a dynamic text box in your document for {&PROMPTXML} .


Execute your document and you will see the XML.



You can now insert the xml using the parameter promptsAnswerXML in the URL.










1 comment:

  1. Hi Anand,

    Nice post.

    I want to pass all the selected values in object prompt or value prompt to in URL dynamically.

    So, If you user has selected multiple values in any types of prompt I want them to be passed in url.

    Note: I am a non microstrategy guy and wants to understand properly so that I can support MSTR team.








    Thanks,
    Abhishek

    ReplyDelete