Using Object Prompts with Documents

Object Prompts are incredibly useful objects that allow you to build some very dynamic experiences in MicroStrategy.  You can customize a report experience with them and alter the layout based on user input.  Unfortunately, it’s not very straightforward to use Object Prompts with Documents.  This is largely due to the Object Prompt being a property of the Grid Report that doesn’t get carried over into a Document. However, there are still some tricks we can do to get the functionality to behave properly in a Document, it just takes a little bit of work.

The Pledge
First, I’ve created an Object Prompt that contains the Region, Cost, Profit and Unit Sold metrics.  The goal is to create a document that will show a trend graph for the single metric that the user chooses from this prompt.  Simple enough, but if we try to create a Document based on this report, it looks like this:

We don’t have any metrics in the data set to add to my document grid.  If we try to run it anyway:
To no surprise, if we run the report, we get a blank graph:
Why does this happen?  The Object Prompt only exists in the scope of the Report, not the Document, so if we look in Design view, we’ll see  as a Dataset Object, but that doesn’t automatically add it to the grid template.  
Since the template is still empty, our graph is empty.  Now what?

The Turn
First, we need to add all of the metrics to the underlying report in addition to the Object Prompt:
Now, if we go to our Document, you’ll notice that we can’t see our Object Prompt.  That’s ok, just add all of the metrics to the template and the Object Prompt should filter them out.  Right?
Wrong …
Source: MicroStrategy Tutorial          Visual: Line Chart DHTML Widget
What happened?  Why did all 4 metrics show up on the graph even though we answered an Object Prompt and only chose Revenue?
The reason is how Object Prompts work.  They’re not a filter, but a placeholder.  When we answered the Object Prompt with “Revenue”, it added the Revenue metric to the template.  The problem is, Revenue was already on the grid template .. as were the rest of the metrics.  The Object Prompt is satisfied because Revenue is already there and all four metrics stay put.  
In a grid report, we would normally put only the Object Prompt on the template and move the metrics into the Report Objects pane.  This way, when the Object Prompt is resolved, only “Revenue” is added to the template.  
However, as previously observed, we don’t see Object Prompts in Documents.  We only see the objects that are on the template of the underlying grid.  We also only see objects that are on the template and not in Report Objects.  This puts us in a predicament. 
Now what?

The Prestige
Here’s the trick.  Add the metrics AND the Object Prompt back to the Report’s template, like we originally had it.

Then go back to the Document, and add ALL of the Metrics to the grid template on the Document:

Save & Close the Document, and now return to the View Report, and move the Metrics back into the Report Objects.

 Save & Close, and when you return to your Document, something magical has happened…

The metrics are no longer available in the Report Objects, but the Document still retains a reference to the original metrics that were originally there.  So what?  Well, what happens now when we run the report …

Success!  Only the Revenue metric displayed.  And if we pick a different metric?

So, why does this work?  The reason has to do with some error handling that is built into the Document.  The Document’s grid template is expecting all 4 metrics.  When we answer the Object Prompt with Revenue, we saw that it adds it to the Data Set Objects in the Document.  This means that the Document grid template’s definition of Revenue is valid, but it’s definition of the other 3 metrics are invalid.  MicroStrategy ignores the references to the other 3 metrics since they don’t exist and we’re left with the only the metric we chose in the prompt!

You may also like...