Hi,
I am trying to fetch the category Id by passing category name as a parameter. Is there method in lapi that we can use.
Hi Mani,
Your question is not clear.
I assume that one or multiple categories are attached to some folder and you are trying to fetch Category ID by passing Category Name.
If this is the case, then following piece of code might help you:
Dim lapi_doc As New LAPI_DOCUMENTS(lapi_ss)
Dim RetVal As Integer
Dim CategoryID As Integer
Dim ObjID As LLValue = New LLValue
Dim catIDList As LLValue = New LLValue
Dim catID As LLValue = New LLValue
ObjID.setAssocNotSet()
ObjID.add("ID", 3043010) 'Enter your Folder Object ID
catIDList.setAssocNotSet()
RetVal = lapi_doc.ListObjectCategoryIDs(ObjID, catIDList)
catID.setAssocNotSet()
For i As Integer = 0 To catIDList.size - 1
If catIDList.toValue(i).ToString("DisplayName") = "GlobalHR" Then ' This is to get Category details by passing Category Name, "GlobalHR" is Category Name
'If catIDList.toValue(i).ToString("ID") = 523641 Then ' This is to get Category details by passing Category Object ID, 523641 is Category ID
catID = catIDList.toValue(i)
CategoryID = catID.toInteger("ID")
End If
Next
Else if you are trying to fetch Category ID in Category workspace or anywhere in the livelink.
Then I am not sure.
We have another function called ListCategories . But that is used to fetch System Categories.
I am not sure, whether that would fetch all the categories.
So you can wait for LAPI experts like Appu, Chris, Kyle…etc to answer.
Regards,
King
Thanks king.
But I am trying to get the Category Id from the category Workspace by passing the category name as parameter
Thanks,
Mani
Correction:
Thanks King. It worked.
We should AVOID HARD CODES.
We have calls to get Volume IDs.
So in place of ‘2004’ use following code:
Dim WSinf As New LLValue
Dim CatWSID As Integer
retval = lapi_doc.AccessCategoryWS(WSinf)
CatWSID = WSinf.toInteger("ID")
Pass CatWSID in place of NodeID.
Appu, thanks for correcting me and suggesting the best practices.