CODE:
Function IsDocumentDuplicate (db As NotesDatabase, viewName As String, _
keyColumnName As String, doc As NotesDocument, errorMsg As String)
IsDocumentDuplicate = False
Dim viewLookup As NotesView
Dim docLookup As NotesDocument
Dim errorString As String
errorString = "Document already exists in the database!"
Set viewLookup = db.GetView(viewName)
If Not viewLookup Is Nothing Then
Set docLookup = viewLookup.GetDocumentByKey(keyColumnName, True)
If Not docLookup Is Nothing Then
If doc.IsNewNote Then
errorMsg = errorString
Exit Function
Else
If doc.UniversalID <> docLookup.UniversalID Then
errorMsg = errorString
Exit Function
End If
End If
Else
errorMsg = "Error getting doc object for lookup document!"
Exit Function
End If
Else
errorMsg = "Error getting view object for lookup document!"
Exit Function
End If
IsDocumentDuplicate = True
End Function
Comments
Post a Comment