Friday, January 13, 2012

URL API hacks for MicroStrategy

Share/Save/Bookmark

This post provides details on the parameters of microstrategy that are exposed by URL API, which can be used to query MicroStrategy data from any external environment(sharepoint/etc.)

Parameters that will be discussed here in the document should be appended/inserted at appropriate places to the Query string or the mstr web url to achieve the functionality.

1. HOW TO ANSWER ATTRIBUTE ELEMENT PROMPTS?
Syntax : &elementPromptAnswers = AttributeGUID;ElementID

Here ElementID is again a combination of AttributeGUID and ID of the actual value or element which is represented as (AttributeGUID:ID)

So the prompt can be answered by using the below url &elementsPromptAnswers=21A808034720FDB2FAA1D3A766CFE861;21A808034720FDB2FAA1D3A766CFE861:136 - Filters report based on the element ID, 136(but not refID, 100)

More Examples :-

&elementsPromptAnswers=21A808034720FDB2FAA1D3A766CFE861; - skips prompt(if optional) and lists all records
&promptAnswerMode = 2 – This can be used as well to skip answering the prompt.

&elementsPromptAnswers=21A808034720FDB2FAA1D3A766CFE861;21A808034720FDB2FAA1D3A766CFE861:100 - Filters report based on the element ID - 100(but not refID)

&elementsPromptAnswers=21A808034720FDB2FAA1D3A766CFE861;21A808034720FDB2FAA1D3A766CFE861:100;21A808034720FDB2FAA1D3A766CFE861:15 - Filters based on mulitple values(100,15) or answering the prompts with multiple values for a single attribute.

&elementsPromptAnswers=21A808034720FDB2FAA1D3A766CFE861;21A808034720FDB2FAA1D3A766CFE861:100,545E8F824DA123EB7CB3B5BAA9FA0529;545E8F824DA123EB7CB3B5BAA9FA0529:125 - Filters based on mulitple prompts or answering multiple prompts each with single value.

2. HOW TO EXECUTE MULTIPLE EVENTS?
Syntax: &src=mstrweb.report.{evt1}&evt={evt1}&src=mstrweb.report.{evt2}&evt={evt2}&evtorder={evt1},{evt2}&{evt1}=1&{evt2}=1

For example, to execute a report and then drill it we need to use events 4001(execute), drill(4096010). Also respective src attributes to be set on which the mstr events(Actions) need to be performed. Finally let microstrategy know the order the events to be raised

Example: http://localhost:8080/webserver/servlet/mstrweb?project=mstrdemo
&evt=4001&src=mstrweb.report.4001&reportID={GUID}&elementPromptAnswers={guid}
&evt=4096010&src=mstrwe.reportrb.vb.4096010&elementList=1A1A0&drillPathKey=0.21.1.1
&retainParent=3&retainThresh=3&evtorder=4001,4096010&4001=1&4096010=1


3. HOW TO TOGGLE THE THRESHOLDS?
Use the event,4066 and param enable(0/1)
Syntax: evt=4066&src=mstrweb&enable=(0-off,1-on)


4. HOW TO OPEN A REPORT WITH “FILTER ON SELECTIONS” ENABLED BY DEFAULT?
Use event,6011
Syntax : &evt=6011


5. HOW TO REMOVE SECTIONS/PANES FROM A REPORT ?
Syntax : &evt=4001&src=mstrWeb.[Option].4001
Option includes one among the below :
- reportNoHeader
- reportNoHeaderNoFooter
- reportNoHeaderNoFooterNoPath
- reportNoHeaderNoFooterNoPathNoToolbar

Example :
&evt=4001&src=mstrWeb.reportNoHeaderNoFooterNoPathNoToolbar.4001

Alternative is &hiddenSections=header,footer,path,dockTop (applicable > 9.0 version)
&reportDetails=0 – Removes report details pane from view
&promptDetails=0 - Removes prompt details pane from view
&vfep=0(view field section)
&vfep=0.-1.0.0


6. EXPORT OPTIONS
Grid Format : &evt=3012&exportFormatGrids=htmlGrids&reportID=E638352311D5C49EC0000C881FDA1A4F

Pdf Format : &evt=3062&src=mstrWeb.3062&showOptionsPage=false
(url should not have reportNoHeaderNoFooterNoPathNoToolbar set)


7. PRESENTATION/VIEW MODES
&reportViewMode=1 (grid)
&reportViewMode=2 (graph)
&reportViewMode=3 (grid/graph)
&visMode=0 (no visualization)
&visMode=51 (AJAX visualization) - this and Flash (50) require that you setup a Custom Visualization in the report definition.
&visMode=50 (Flash visualization)


8. PRESENTATION MODE FOR DOCUMENTS
Syntax : &currentViewMedia={number}

Options :
Interactive DHTML view mode (2)
Flash view mode (8)
Export to Excel (16)
Export to PDF (32)

Example : &currentViewMedia=16


Subscribe

Remove format copy paste text editor

Share/Save/Bookmark
How do i avoid the formatting that comes along when i copy paste is done from a site or word document to the Rich Text Editor (RTE) field in sharepoint? Ofcourse RTE already have an option Clear Formatting that can be used to clear after pasting the content,, but i do not want the format to be copied at first. So after digging into SP.UI.RTE.js and googling i have come up with some script that will fulfill my needs.

function disableMarkupPasteForRTE()
{

Type.registerNamespace("RTE");
if (RTE)
{

if(RTE.RichTextEditor != null)
{
     RTE.RichTextEditor.paste = function() { RTE.Cursor.paste(true); }

     // Set Ctrl+V Flag

     RTE.Cursor.$3C_0 = true;
}
}
}

I used the below standard sharepoint javascript function that will run the above or any javascript function on load of page


_spBodyOnLoadFunctionNames.push("disableMarkupPasteForRTE");



 Subscribe

Localizing Sharepoint using Resource files

Share/Save/Bookmark
Resource files on a high level can be stored either under 14 hive or at {webappRoot}\app_globalResources


Shared Resource:

How To Create?

Create a mapped folder in VS to deploy the shared or localized resource file to a specific resources folder under 14 hive.

How To Use?

Feature.xml :- Resource(shared) file located at 14/Resources can be accessed in feature xml by setting the DefaultResourceFile property. Now feature will look for the resource file at 14/Resources but not under 14/template/features/featureName/resources(which is default behavior)

Code:- Programmatically same resource file can be accessed using

SPUtility.GetLocalizedString(Key, ResourceFileName, (uint)CultureInfo.CurrentUICulture.LCID);


Global Resource:

How To Create?

To have a Resource(global) file that will be located at {webappRoot}\app_globalResources
We can use a global resource template in VS2010. If its missing add an empty item to VSproject and under that add a resource file or which the deployment path will be set to {webappRoot}\app_globalResources

How To Use?

Feature.xml :- Resource(shared) file located at 14/Resources can be accessed in feature xml by setting the DefaultResourceFile property. By default feature will look for the resource file at 14/Resources but not under 14/template/features/featureName/resources

Code:- GlobalResources can be accessed using
HttpContext.GetGlobalResourceObject(“ResourceName”,”key”,CultureInfo.CurrentUICulture)

Markup :- <%$Resources:ResourceFilename,StringKey%>


Gotchas:

If aspx files(markup) are not picking up the resx files based on the culture but just the fallback(default) resource file, then you might need to check the following :

- Set UICulture=”auto” for the Page directive

- Add the below tag to web.config

<globalization uiCulture="auto" enableClientBasedCulture=”true” culture="auto" />

I’ll try to get a new post for the localized resources that reside under app_localresources(for .aspx files)




Subscribe