views:

53

answers:

1

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?

+1  A: 

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.

shrub34
I am going to test this out. I was looking at the getSubGroups but, the API documentation for it didn't pop out at me. I will let you know.
tathamr
Worked like a charm for XI R3. Thank you!
tathamr
I agree that the API docs don't pop for this and I really do have to give thanks to the BOB Forum for figuring it out.Good to know that it works for R3, since we are just starting our upgrade (though don't use this currently).
shrub34