Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
multi-level categories with SDK
Ben_inform
When i try and add one category under my matters its works but if i try and creat two at the same time the code fails when i call the iCat.SubFolders.
This code is supposed to create a two level category tree. If I run it once it wll creat only the top level and then fail. If I run it a second time it will create the second level and then fail. running the third time it will add the workspace to it.
The code seems to not be able to call *.subfolders on a newly created category in the same execution thread.
Running the code again (with the category existing) permits the subfolders call.
1) Is this a known issue
2) can u reproduce?
3) how can i work around (assuming my code is valid)?
'objWorkArea is a valid IManWorkArea object.
Dim oCats As IManSubscriptionFolders
Dim oCat As IManSubscriptionFolder
Dim oWorkspaceShortCuts As IManWorkspaceShortcuts
Dim oWorkspaceShortcut As IManFolderShortcut
Dim oWorkArea As IManWorkArea
Dim iCat As IManSubscriptionFolder
Set oWorkArea = isess.WorkArea
Set oCats = oWorkArea.SubscriptionFolder.SubFolders
Set iCat = GetCategory(oCats, "50000 Series")
' Next line may crash
Set oCats = iCat.SubFolders
Set iCat = GetCategory(oCats, "ACTIVE Jobs")
Dim oCats2 As IManSubscriptionFolders
Dim oCat2 As IManSubscriptionFolder
Dim oWorkArea2 As IManWorkArea
Dim iCat2 As IManSubscriptionFolder
' Next line may crash
Set oWorkspaceShortCuts = iCat.SubFolders
Set oWorkspaceShortcut = oWorkspaceShortCuts.AddNewWorkspaceShortcutInheriting(m_workspace)
'--------------------------------------------------------------------------------------
Function GetCategory(oCats As IManSubscriptionFolders, match As String) As IManSubscriptionFolder
Dim tempCat As IManSubscriptionFolder
Dim matchCat As IManSubscriptionFolder
For Each tempCat In oCats
If tempCat.name = match Then
fFound = True
Set matchCat = tempCat
End If
Next
If Not fFound Then
Set matchCat = oCats.AddNewSubscriptionFolderInheriting(CStr(match), "description")
oCats.Refresh
Else
Set GetNextCats = matchCat
End If
End Function
Find more posts tagged with
Comments
Weiqun
It looks like matchCat was never returned from function: "GetCategory", instead of using matchCat, if you use
Set GetCategory = oCats.AddNewSubscriptionFolderInheriting(CStr(match), "description")
you should be able to create a sub category.
BTW, the "For" loop might not work if you have other object types in the oCats collections, it will throw an exception. So I modified the code as the following:
Dim tempCat As IManFolder
For Each tempCat In oCats
Dim objectType As IManage.IManObjectType
Set objectType = tempCat.objectType
If objectType.objectType = imTypeSubscriptionFolder Then
If tempCat.Name = match Then
fFound = True
Set matchCat = tempCat
Exit For
End If
End If
Next
Weiqun
jny
Acutally, you may want to know that in 8.0 you can do folder search via IManWorkArea.SearchProfiledFolders instead of iterating through the folder collection.