Hi All,
I have a query to check if there is a chance of having same docUNID for more than 1 doc across multiple databases, i.e…
-
Is it possible that two documents have same “DocUNID”?
-
The form contain a ref# for that document and is generated using the command “@Unique”. Is there chance that more than one document has same ref#.
If the answer is yes then how to track it out.
Thanks and Best Regards
Ravi
Subject: Is there a way to find - two documents sharing same DocUNID across different db.
Hey Ravi,
-
No. UINDs are unique.
-
Not sure. @Unique returns a random unique text value. If this is a psudeorandom number then it is likely to be unique but there is a statistical possibility that it is not unique.
You can scan for ref# collisions with other databases by putting a single-colunm view in each database that contains and is sorted by Ref# and writing an agent to use the views to scan for ref# collisions. For example:
Dim OtherDb as New NotesDatabase(“OtherServer”, “OtherDatabase”)
Dim lu as NotesView
Dim ReturnDoc as NotesDocument
Dim AllDocs as NotesDocumentCollection
Dim ThisDoc as NotesDocument
Dim session as New NotesSession
Set lu = OtherDb.GetView(“RefLookup”)
Set AllDocs = session.CurrentDatabase.Search({@IsAvailable(“Ref#”)}, Nothing, 0)
Set ThisDoc = AllDocs.GetFirstDocument()
Do Until ThisDoc is Nothing
Set ReturnDoc = lu.GetDocumentByKey(ThisDoc.RefNo(0), True)
If Not ReturnDoc Is Nothing Then
Print "Found One!"
End If
Set ThisDoc = AllDocs.GetNextDocument(ThisDoc)
Loop
HTH
Subject: RE: Is there a way to find - two documents sharing same DocUNID across different db.
UNIDs are unique across all replicas of a database, but documents in non-replicating databases may have the same UNID but different data. This normally happens if a document is copied from one database to another, but it can also be forced by writing to the NotesDocument.UniversalID.
@Unique is guaranteed unique under almost all conditions. It consists of a user identifier (the first four characters) and a time stamp (not a random number). The time component will be incremented for each call to the function if that user ID calls the function more rapidly than the resolution of the time stamp, with “slack” given back once the calls stop. Obviously, if the same ID is calling @Unique on two different machines at exactly the same time, you can wind up with colliding values since neither machine will be aware of the values used on the other.
Subject: Is there a way to find - two documents sharing same DocUNID across different db.
You can also use the GetDocumentbyUNID method of the Notesdatabase class,
If a valid Doc is returned then the UNID exists in target db
Subject: RE: Is there a way to find - two documents sharing same DocUNID across different db.
random numbers generated with @unique depends on the scrambling of date and the Replica ID of the databases.If you have a change of having Databases sharing same replica ID there is a possibility of duplications.