2010-03-04 50 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