All,
I add a group to be a child of the parent group but, it is not becoming a member of the parent group. I have to go in and set it manually.
Anyone know how this works?
All,
I add a group to be a child of the parent group but, it is not becoming a member of the parent group. I have to go in and set it manually.
Anyone know how this works?
I had to play with it and do a little research on the BOB Forum but I figured it out, though its non-intuitive.
I'm going to assume you know how to get the parent group IUserGroup object.
// get the plugin manager
IPluginMgr pluginMgr = store.getPluginMgr();
// Retrieve the User plugin.
IPluginInfo groupPlugin = pluginMgr.getPluginInfo("CrystalEnterprise.UserGroup");
// Create a new InfoObjects collection.
IInfoObjects newInfoObjects = store.newInfoObjectCollection();
// Add the User plugin to the collection.
newInfoObjects.add (groupPlugin);
// Retrieve the newly created user object.
IUserGroup newUserGroup = (IUserGroup)newInfoObjects.get(0);
// build the new group
String newGroupName = "My Test Group";
newUserGroup.setTitle(newGroupName);
newUserGroup.setDescription("Just for sample test code");
store.commit(newInfoObjects);
// now that things commited associate the parent group
if(parentGroup != null)
{
parentGroup.getSubGroups().add(new Integer(newUserGroup.getID()));
store.commit(parGroupObjs);
}
The big stumper is that you you would expect to just use the setParentID() method. Word of warning this this was only tested under BO XI R2, not R3, so it may not be 100% correct for the current version.