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

KB46419: How to Add Attribute Forms to a Report Services Document Grid Programmatically Using the MicroStrategy Web SDK 9.4.x-9.5.x


Community Admin

• Strategy


Java example demonstrating how to add attribute forms to an existing document with the MicroStrategy Web SDK.

Users may want to add attribute forms to a document grid programmatically. The below code samples shows how to use the addAttributeForm() method on RWManipulator to do this. The gridKey can be found either in the page source or programmatically through the RWDefiniton, RWUnitDef.getKey().


package com.Strategy.sdk.standalone;

import com.Strategy.web.beans.FolderBean;
import com.Strategy.web.beans.RWBean;
import com.Strategy.web.beans.WebBeanException;
import com.Strategy.web.beans.WebBeanFactory;
import com.Strategy.web.objects.WebFolder;
import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebObjectsException;
import com.Strategy.web.objects.WebObjectsFactory;
import com.Strategy.web.objects.rw.RWInstance;
import com.Strategy.web.objects.rw.RWManipulation;
import com.Strategy.webapi.EnumDSSXMLApplicationType;
import com.Strategy.webapi.EnumDSSXMLDocSaveAsFlags;

public class test { 

	 private static WebObjectsFactory factory = null;
	 private static WebIServerSession serverSession = null;

	 public static void main(String[] args) throws WebObjectsException, IllegalArgumentException, WebBeanException {
		  
		if (serverSession == null) {    
			   // create factory object
			   factory = WebObjectsFactory.getInstance();
			   serverSession = factory.getIServerSession();

			    // Set up session properties
			   serverSession.setServerName("servername"); // Should be replaced with the name of an Intelligence Server
			   serverSession.setServerPort(0);
			   serverSession.setProjectName("Strategy Tutorial"); // Project where the session should be created
			   serverSession.setLogin("userID"); // User ID
			   serverSession.setPassword("password"); // Password
			   serverSession.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);

			  
		}
		  String docID = "DBC850344EA83F9312D38ABCC8F9B462";
		  String attributeID = "8D679D3C11D3E4981000E787EC6DE8A4"; //customer
		  String formID = "8D67A35B11D3E4981000E787EC6DE8A4"; //Last Name

		   //Getting document instance
		  WebBeanFactory factory = WebBeanFactory.getInstance();
		  RWBean rwb = (RWBean) factory.newBean("RWBean");
		  rwb.setSessionInfo(serverSession);
		  rwb.setObjectID(docID);
		  rwb.initBean();
		  RWInstance rwi = rwb.getRWInstance();

		   // Getting parent folder to use when saving later
		  FolderBean fb = rwb.getParentFolderBean("fb");
		  WebFolder parentFolder = fb.getFolderObject();
		  System.out.println("Parent Folder: " + parentFolder.getName());
		  String docName = rwb.getDisplayName();
		  System.out.println("Document Name: " + rwb.getDisplayName());

		   //Use RWmanipulation to add attribute form
		  RWManipulation rwmanip = rwi.getRWManipulator();
		  rwmanip.addAttributeForm("W44", attributeID, formID, 2);

		   //Getting new doc instance
		  RWInstance newInst = rwi.getRWManipulator().applyChanges();

		   // Saving the document as a NEW document
		  rwi.setSaveAsFlags(EnumDSSXMLDocSaveAsFlags.DssXmlDocSaveAsOverwrite);
		  newInst.saveAs(parentFolder, docName);	 
	}
}

 
 


Comment

0 comments

Details

Knowledge Article

Published:

May 8, 2017

Last Updated:

February 13, 2024