Need to a column to show if a Document Number is Unique

Hello,

I need to create a column in a view that just displays “This is Unique” or “This is not Unique” Refering to a field called “Document Number”.

Thanks,

Jeff

Subject: Need to a column to show if a Document Number is Unique

No way.

You can’t do this with a view.

But.

You can categorize the document number (first column), add a column with value 1 and set this column to summarize with details.

This way, category with two or more document will show 2…n documents.

Hope this help.

Regards

AD

Subject: Need to a column to show if a Document Number is Unique

Dear Jeff,

You can copy the below code in an agent, supposing you have a sorted view based on the DocumentNumber field, and also a CompareField in your form that will contains the Unique or Not value.

I have also supposed that your “DocumentNumber” field was a Number field.

You can modify the code to suit your needs if it’s not the case.

Hope this helps,

Christine

Dim session As New NotesSession

Dim dbCurrent As NotesDatabase

Dim view As NotesView

Dim vc As NotesViewEntryCollection

Dim doc1 As Notesdocument

Dim table() As String

Dim value As Long

Dim test As String

Dim i As Integer

Dim counter As Integer

Set dbCurrent = session.currentDatabase

Set view = DbCurrent.GetView(“SortedViewName”)

Set doc1 = view.GetFirstDocument

i =1

Redim table(1 To i)

While Not (doc1 Is Nothing)

value = doc1.DocumentNumber(0)

test = ExistinArray (table(), Cstr(value))

If test = False Then

	Redim Preserve table (1 To i)

	table (i) = value

	i=i+1

	End If

Set doc1 = view.GetNextDocument (doc1)

Wend

counter =1

For counter = 1 To i-1

Set vc = view.GetAllEntriesByKey(Clng(table(counter)), True)

	

If vc.Count <> 1 Then

	Call vc.StampAll ("CompareField", "This is not Unique")

Else

	If vc.Count = 1 Then

		Call vc.StampAll ("CompareField", "This is Unique")

	End If

End If

Next

Function ExistInArray(t() As String, s As String) As Boolean

Dim i As Integer

ExistInArray = False

i = Ubound(t)

If Strcompare(t(i), s, 1) = 0 Then

ExistInArray = True

End If

End Function

Subject: RE: Need to a column to show if a Document Number is Unique

Christine,

Wow, thanks for that. Your asumptions are correct.

I put the code you gave me into a button on the view. However, when I click it, I get an error message saying that “Variant does not contain an object”. Any ideas about what this could be?

Subject: RE: Need to a column to show if a Document Number is Unique

Hi Jeff,

Did you make a test with the LotusScript debugger, to see where the problem is located ?