'**********************************************************************************
'@Author : Karthikeyan A
'@Purpose : To get the names of all the desing elements from a database
'@Type : Function
'@Name : getDesignNames
'@Param : targetDB - the database from which the design names needs to be assimilated
'@Return : variant - array of design names
'**********************************************************************************
Function getDesignNames(targetDB As NotesDatabase) As Variant
'declare all variables and functions necessary for further manipulation
Dim nc As NotesNoteCollection
Dim designDoc As NotesDocument
Dim noteID As String
Dim designNames As String
Dim designItr As Integer
Dim designTitle As String
'handle errors in case of abrupt termination
On Error Goto errHandler
'create a note collection of all the design elements in the database
Set nc=targetDB.CreateNoteCollection(True)
Call nc.BuildCollection()
'get the first note id from the collection
noteID=nc.GetFirstNoteId
'set the handle of the design document associated with the above mentioned noteid
Set designDoc=targetDB.GetDocumentByID(noteID)
'loop through all the design documents and get their titles
designItr=0
While Not designDoc Is Nothing
designItr=designItr+1
'ensures that you are saved from an infinite loop
If designItr>nc.Count Then Goto loopOut
designTitle=designDoc.GetItemValue("$Title")(0)
designNames=designNames+designTitle+"$#$"
noteID=nc.GetNextNoteId(noteID)
Set designDoc=targetDB.GetDocumentByID(noteID)
Wend
loopOut:
designNames=Strleftback(designNames,"$#$")
Msgbox designNames
'explode the concatenated design element names and return the same
getDesignNames=Split(designNames,"$#$")
Exit Function
'prompt the errors that resulted in abrupt termination
errHandler:
'to by pass invalid noteId error
If Err=4270 Then Goto loopOut
Msgbox "Error: ***" & Error & "*** encountered on line *** " & Cstr(Erl) & " *** with error number *** " & Cstr(Err) & " ***"
Exit Function
End Function
No comments:
Post a Comment