Embedding HTML in Attributes (part 1)

Author: Bit Software
Date: 19- 10- 2011

Since MicroStrategy is primarily consumed via the Web, there is a unique opportunity to embed some extra value by slipping HTML into little pockets of a report. While the HTML Container for Documents is obviously designed to do just that, you can also sneak it into Attributes which can help solve some pretty neat problems. Today I'll talk about how HTML Attributes work and a few use cases.

All of these tricks are going to be built off of the simple technique of using ApplySimple's in Attribute Form definitions. An ApplySimple is a Database Passthrough Function, which allows you to custom build the SQL for the Attribute Form. We're going to use that to generate some HTML code that will eventually be rendered on the Web.

Secondly, regardless of what Data Type the underlying column or columns are, we'll need to choose HTML Tag as the Attribute Form Type. This is a signal to MicroStrategy that we'll be returning HTML so that it can be sure to parse it correctly.

It's also important to note that since we're embedding HTML, consuming the report through anything other than Web (Desktop, Mobile, Office) won't properly resolve the HTML and will instead display the ugly code. Flash mode supports a few of the basic formatting tags, so there could be some hope there.

Adding Images
One of my favorite tricks is to use this to add Pictures to reports. While there is an Attribute Form Type specifically for Pictures, I highlighted a use case in the Report Search Tool post where you'd want to have the image and text side by side.

To implement this, we just need to build the simple HTML string to use the <img> tag and append the text afterwards: ApplySimple("'<img src=' + #0 + '>&nbsp;&nbsp;' + #1", [Object_Image], [Object_Desc])

In this example, the database contains the column Object_Image which contains the URL to the image.



by Bryan Brandow

(This article was first published on Bryan`s MicroStrategy Blog)