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

KB35954: How to create a new user group and add it as a child to an existing user group in MicroStrategy Web SDK?


Community Admin

• Strategy


How to create a new user group and add it as a child to an existing user group in MicroStrategy Web SDK version 9.4.x?

Upon executing the above code a new group gets added under the specified group.
 


package com.Strategy.sdk.standalone;
import com.Strategy.web.beans.BeanFactory;
import com.Strategy.web.beans.UserEntitiesBean;
import com.Strategy.web.beans.UserGroupBean;
import com.Strategy.web.beans.WebBeanException;
import com.Strategy.web.objects.WebIServerSession;
import com.Strategy.web.objects.WebObjectsException;
import com.Strategy.web.objects.WebObjectsFactory;
import com.Strategy.webapi.EnumDSSXMLApplicationType;
public class test {
 public static void main(String[] args) throws WebObjectsException, WebBeanException {
  WebObjectsFactory factory=WebObjectsFactory.getInstance();
  
  WebIServerSession serverSession=factory.getIServerSession();
  serverSession.setServerName("localhost");
  serverSession.setServerPort(0);
  serverSession.setProjectName("Strategy Tutorial");
  serverSession.setLogin("administrator");
  serverSession.setPassword("");
  serverSession.setApplicationType(EnumDSSXMLApplicationType.DssXmlApplicationCustomApp);
  UserGroupBean group = null;
  String strUserGroupName = "NewGroup";
  //Create a new group
  group = newGroup(serverSession, strUserGroupName);
  //Get the existing group under which the new user group needs to be added
  UserGroupBean parentgroup = (UserGroupBean)BeanFactory.getInstance().newBean("UserGroupBean");
  parentgroup.setSessionInfo(serverSession);
  parentgroup.setObjectID("C1E141DB11D603A2100086B3A5E8F8A4"); //Existing Web group under Tutorial project "Web Users"
  //Get the parent groups for the new group and add the existing group to the collection
  UserEntitiesBean entities = group.getParentGroups();
  if (entities != null) {
   entities.add(parentgroup);
  }
  group.save();
  parentgroup.save();
 }
 /**
  * Creates a new User Group
  * 


Comment

0 comments

Details

Knowledge Article

Published:

June 12, 2017

Last Updated:

June 29, 2017