EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB439872: How to interpret the viewMedia property returned by the MicroStrategy REST API 10.10?


Community Admin

• Strategy


This article demonstrates how the viewMedia property returned by the MicroStrategy REST API can be used to differentiate between documents, dossiers, and other view modes using a bitwise operation.

Starting with the release of Strategy ONE (March 2024), dossiers are also known as dashboards.
The Browsing API within the Strategy REST API returns JSON structures similar to the following, for individual metadata objects returned by the API:


{
	"name": "Balanced Scorecard",
	"id": "DBFC517111E56C3A18EE0080EF85F392",
	"type": 55,
	"description": "This document shows a complete balanced scorecard, along with a graphical strategy map at the bottom. The targets for the KPI's come from an external data mart and are incorporated using a report built in Query Builder.",
	"subtype": 14081,
	"extType": 0,
	"dateCreated": "2015-10-06T20:29:36.000+0530",
	"dateModified": "2016-08-13T01:02:54.000+0530",
	"version": "1BCD06B5415E36EA3060319633B3BAAE",
	"acg": 255,
	"viewMedia": 268435695,
	"owner": {
		"name": "Administrator",
		"id": "54F3D26011D2896560009A8E67019608"
	}
},
{
	"name": "The 2014 BNY Mellon Boat Race",
	"id": "371E250C11E5BEFB00000080EF85899C",
	"type": 55,
	"subtype": 14081,
	"extType": 0,
	"dateCreated": "2016-01-20T03:53:10.000+0530",
	"dateModified": "2016-08-13T01:03:17.000+0530",
	"version": "DD4785C447F7858EEAF7AF9D8A975A80",
	"acg": 255,
	"viewMedia": 1879056553,
	"owner": {
		"name": "Administrator",
		"id": "54F3D26011D2896560009A8E67019608"
	}
}

Both objects in this example share the same type and subtype, yet the first is a document while the second is a dossier. The viewMedia property contains information such as default view mode, available view mode, etc; in the format of a 32 bit value. This can be used to differentiate between a report services document and a dossier using a bitwise operation.
The following javascript demonstrates how this operation can be performed using the value in the viewMedia property:

/**
 * Mapping of the EnumDSSXMLViewMedia bits from Strategy WebSDK
 */
const EnumDSSXMLViewMedia = {
    DssXmlViewMediaReserved: 0x00000000,
    DssXmlViewMediaViewStatic: 0x00000001,
    DssXmlViewMediaViewInteractive: 0x00000002,
    DssXmlViewMediaViewEditable: 0x00000004,
    DssXmlViewMediaViewFlash: 0x00000008,
    DssXmlViewMediaExportExcel: 0x00000010,
    DssXmlViewMediaExportPDF: 0x00000020,
    DssXmlViewMediaExportHTML: 0x00000040,
    DssXmlViewMediaExportFlash: 0x00000080,
    DssXmlViewMediaExportExcelPlainText: 0x00000100,
    DssXmlViewMediaExportCSV: 0x00000200,
    DssXmlViewMediaExportPlainText: 0x00000400,
    DssXmlViewMediaViewAnalysis: 0x00000800,
    DssXmlViewMediaCustomSQL: 0x00001600,
    DssXmlViewMediaHTML5Dashboard: 0x00002000,
    DssXmlViewMediaExportMSTR: 0x00004000,
    DssXmlViewMediaPrivate: 0x00008000,
    DssXmlViewMediaAvailableServeAsModel: 0x00010000,
    DssXmlViewMediaExportPhone: 0x00020000,
    DssXmlViewMediaExportTablet: 0x00040000,
    DssXmlViewMediaExportJSON: 0x00080000,
    DssXmlViewMediaStatic: 0x08000000,
    DssXmlViewMediaAll: 0x7FFFFFF
};


var DOCUMENT_TYPES = Object.freeze({
    "DOSSIER": EnumDSSXMLViewMedia.DssXmlViewMediaHTML5Dashboard,
    "RSD": EnumDSSXMLViewMedia.DssXmlViewMediaViewStatic})


/**
 * Get default mode from given viewMedia
 */
function getDefaultViewMode(viewMedia) {
    const defModePosition = viewMedia >> 27;

    if (defModePosition == 0) {
        return 0;
    }
    return EnumDSSXMLViewMedia.DssXmlViewMediaViewStatic << defModePosition - 1;
}


/**
 * Map the documents default view media to the type of document, which can be Dossier or RSD.
 */
function getTypeFromViewMedia(viewMedia) {
    var defaultViewMedia = getDefaultViewMode(viewMedia);
    if (!defaultViewMedia) {
        return null;
    }
    if(defaultViewMedia & EnumDSSXMLViewMedia.DssXmlViewMediaViewAnalysis |
        defaultViewMedia & EnumDSSXMLViewMedia.DssXmlViewMediaHTML5Dashboard) {
        return DOCUMENT_TYPES.DOSSIER;
    } else if(defaultViewMedia & EnumDSSXMLViewMedia.DssXmlViewMediaViewStatic) {
        return DOCUMENT_TYPES.RSD;
    }
    return null;
}

/**
 * function to determine if a provided view media is for an rsd
 * @param viewMedia
 * @returns {boolean}
 */
function isRsd(viewMedia) {
    return getTypeFromViewMedia(viewMedia) == DOCUMENT_TYPES.RSD;
}

/**
 * function to determine if a provided view media is for an dossier
 * @param viewMedia
 * @returns {boolean}
 */
function isDossier(viewMedia) {
    return getTypeFromViewMedia(viewMedia) == DOCUMENT_TYPES.DOSSIER;
}

While this example is written in javascript, the concepts driving this example can be ported over to any language.
 
ADDITIONAL INFORMATION:
The Strategy SDK allows you to customize several Strategy products and extend and integrate the Strategy business intelligence functionality into other applications. However, before changing the way Strategy products look or behave, it is helpful to understand how the application is built. For more information regarding the Strategy products or the process of customizing Strategy products, please refer to Strategy Developer Zone (https://developer.microstrategy.com).
To access the Strategy Developer Zone, you must have access to the Strategy Knowledge Base, you must have purchased the Strategy SDK, and you must be current on your Strategy maintenance agreement. If you are a US-based business and believe that you satisfy all three of these conditions but you do not have access to the Strategy Developer Zone, please contact Strategy Technical Support at support@microstrategy.com or at (703) 848-8700. If you are an international business, please contact Strategy Technical Support at the appropriate email address or phone number found at https://www.microstrategy.com/us/services/support/contact.
CUSTOMIZATION WARNING:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy Technical Support makes no guarantee that an updated version of this particular customization will be provided. In the event of a code change in future builds, Strategy may not be able to provide additional code on this matter even though this customization is provided at this time for this specific build. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about Strategy Consulting assistance.
KB439872


Comment

0 comments

Details

Knowledge Article

Published:

March 8, 2018

Last Updated:

March 21, 2024