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

KB203216: How to Programmatically Create a New Report with Data and Set its Graph Type Using the MicroStrategy Web SDK 9.4.x


Community Admin

• Strategy


How to Programmatically Create a New Report with Data and Set its Graph Type Using the MicroStrategy Web SDK 9.4.x

SUMMARY: This Technical Note shows how a user can programmatically create a new report, add data to it then choose the type of graph he/she’d like to display with Strategy Web SDK 9.4.x.
 
The following code demonstrates how to programmatically create a new report with data and set its graph type using Strategy Web SDK 9.4.x:
 
//Create an empty report
WebReportInstance reportInstance = reportSource.getNewInstance("05B202B9999F4C1AB960DA6208CADF3D");
//Add attribute and metric to the template
WebTemplate template = reportInstance.getTemplate();
WebObjectInfo atrb1= objectSource.getObject("8D679D5111D3E4981000E787EC6DE8A4", EnumDSSXMLObjectTypes.DssXmlTypeAttribute);
template.add(atrb1,EnumDSSXMLAxisName.DssXmlAxisNameRows, 1 );
WebObjectInfo attrb2= objectSource.getObject("8D679D3711D3E4981000E787EC6DE8A4", EnumDSSXMLObjectTypes.DssXmlTypeAttribute);
template.add(attrb2, EnumDSSXMLAxisName.DssXmlAxisNameColumns, 1);
WebTemplateMetrics wtm = template.getTemplateMetrics();
template.addMetrics(EnumDSSXMLAxisName.DssXmlAxisNameColumns, 2);
WebObjectInfo metric1= t.objectSource.getObject("7FD5B69611D5AC76C000D98A4CC5F24F", EnumDSSXMLObjectTypes.DssXmlTypeMetric);
wtm.add(metric1);
 //Retrieve the folder to save the report
String folderID = objectSource.getFolderID(EnumDSSXMLFolderNames.DssXmlFolderNamePublicReports);
WebFolder folder = (WebFolder) t.objectSource.getObject(folderID, EnumDSSXMLObjectTypes.DssXmlTypeFolder);
 //Select the graph type and apply changes
WebReportManipulation wrpManip = reportInstance.getReportManipulator();
WebGraph g = reportInstance.getGraphObject();
g.getGraphProperties().setMajorType(<Graph Type>);
wrpManip.setResultFlags(wrpManip.getResultFlags() | EnumDSSXMLResultFlags.DssXmlResultGraph);
reportInstance = wrpManip2.applyChanges();
reportInstance.setAsync(false);
reportInstance.setMaxWait(-1);
reportInstance.pollStatus();
reportInstance.setSaveAsDisplayMode(EnumDSSXMLDisplayMode.DssXmlDisplayModeGraph);
 reportInstance.setSaveAsFlags(EnumDSSXMLReportSaveAsFlags.DssXmlReportSaveAsOverWrite);
reportInstance.saveAs(folder, "myGraph");
reportInstance.pollStatus();
 
 
ADDITIONAL INFORMATION:
 
The Strategy SDK allows you to customize the standard Strategy Web interface, and extend and integrate the Strategy business intelligence functionality into other applications. However, before changing the way Strategy Web products look or behave, it is helpful to understand how the application is built. For more information regarding the Strategy Web architecture or the process of customizing Strategy Web, please refer to Strategy Developer Zone (https://resource.microstrategy.com/msdz/).
 
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. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about Strategy Consulting assistance.
 


Comment

0 comments

Details

Knowledge Article

Published:

June 12, 2017

Last Updated:

July 17, 2017