Tuesday, November 04, 2008

How to retrieve IS Document Class Index fields summary?

Question : How to retrieve the Index names and their types of an IS document class.
Answer : Following code can do it for you.

Dim oClassDesc As IDMObjects.ClassDescription
Dim oLib As IDMObjects.Library
Dim oPropDesc As IDMObjects.PropertyDescription
Dim oPropDescs As IDMObjects.PropertyDescriptions

Set oLib = CreateObject("idmObjects.Library")
oLib.SystemType = idmSysTypeIS
oLib.Name = sISServerName
oLib.Logon "username", "password", "", idmLogonOptNoUI
Set oClassDesc = oLib.GetObject(idmObjTypeClassDesc, sDocClassName, idmObjTypeDocument)
'lstSource is a list control
Set oPropDescs = oClassDesc.PropertyDescriptions
If Not oPropDescs Is Nothing Then
For Each oPropDesc In oPropDescs
If InStr(1, oPropDesc.Name, "F_") = 0 Then
lstSource.AddItem oPropDesc.Name + " - " + FormatDataType(oPropDesc.TypeID) + " - " + Str(oPropDesc.GetState(idmPropRequired)) + " - " + Str(oPropDesc.Size) + " - IsKey " + Str(oPropDesc.GetState(idmPropKey))

End If

Next
End If

oLib.Logoff
Set oPropDesc = Nothing
Set oPropDescs = Nothing
Set oClassDesc = Nothing
Set oLib = Nothing