2010-03-04 46 views
0

All,BOBJ SDK Add Group MemberOf Parent Group

我添加一个组作为父组的子组,但它并未成为父组的成员。我必须进入并手动设置它。

任何人都知道这是如何工作的?

+0

这是用于用户组的吗? – shrub34 2010-03-05 15:27:36

+0

是的我试图添加一个用户组成为另一个用户组的成员。 – XanderLynn 2010-03-05 17:20:07

回答

2

我不得不玩弄它,并在BOB Forum上做了一点研究,但我想通了,虽然它不直观。

我打算假设你知道如何获得父组IUserGroup对象。

// 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); 
} 

大的问题是,你会希望只使用setParentID()方法。警告这个词只在BO XI R2下测试,而不是R3,因此它对于当前版本可能不是100%正确的。

+0

我要测试一下。我正在查看getSubGroups,但是它的API文档没有出现在我身上。我会让你知道的。 – XanderLynn 2010-03-06 16:38:12

+0

像XI R3的魅力一样工作。谢谢! – XanderLynn 2010-03-07 17:09:54

+0

我同意API文档不会为此而弹出,我真的不得不感谢BOB论坛来找出答案。 很高兴知道它适用于R3,因为我们刚刚开始升级(尽管目前不使用它)。 – shrub34 2010-03-08 14:23:39