Falling Dominos | Let's keep Lotus Notes development relevant

Common Name Duplicates in Lotus Notes

Legacy databases… you just have to love them. I was working with a database the other day which stored names in the Common Name format (big no-no) instead of the Abbreviated Name. That’s cool if you work in a small company or if your Administrators do not allow duplicate user names.

Using the Common Name causes two major problems.

* If you are using the common name for security (comparing @Name([CN]) to the stored name) you might have a second user out there with the same name that should not be accessing the data
* Duplicate common names break mailing scripts.

I created this code to use in the Notes Client UI to check for duplicate names. It seems to run pretty fast with our 50,000 entry address book. I wouldn’t suggest continuously running it in script but it is good for validation.

Function checkForCNDupes(commonName As String) As String
	' Check for common name duplicates. Force user to choose the correct option
	' assumes we are using the client UI (workspace)
	checkForCNDupes = ""
	If commonName = "" Then
		Exit Function
	End If

	Dim evalString As String
	Dim check_CN As Variant
	Dim response As String

	evalstring = {@Name([ABBREVIATE];@NameLookup ([NOSEARCHING];"} + commonName + {";"Owner"))}
	check_CN = Evaluate(evalstring)

	Print Ubound(check_CN)

	If (Ubound(check_CN) > 0) Then
		Dim workspace As New NotesUIWorkspace
		response = workspace.Prompt (PROMPT_OKCANCELLIST, _
		"Multiple users found", _
		"Multiple names were found in the address book for your selection. Please pick the correct user.","",check_CN)
		If Isempty (response) Or response = "" Then
			Messagebox "You must select the correct name before continuing." , 16, "Update canceled"
			Exit Function
		Else
			checkForCNDupes = response
		End If
	Else
		checkForCNDupes = check_CN(0)
	End If
End Function
 

Essentials