Hi guys,
I have a view on a database called “0” within this view are 5 records. One of the columns within this view has a column value of:
@Text(@DocumentUniqueID)
Within the notes client i am able to see the unique number string however i need to modify one of them.
Basically i have a string that says:
a1bc0d239deaa94f8025740200402b46
And i need it to say:
a1bc0d239deaa94f8025740200402b47
Any suggestions? I was thinking about writing an agent to modify the value of this field however there is no field that displays this in the document properties.
Thanks.
Subject: Modifying the @DocumentUniqueID
Viraj,
I’m not positive how to go about doing that but I’ve been in your position before and believe me, using @Text(@DocumentUniqueID) as your key can be a headache since that key is subject to change if you have to cut/paste a document. We’ve been using a field named something like “ProjectHiddenKey” (for instance) and giving it a computed when composed value of @Unique. That way, you will have a unique look-up key that won’t get messed up if you have to cut/paste a document. It’s VERY reliable for cross database look-ups as well.
It’s pretty easy to write a script to populate a field like that as well and once you have it, you can pass it down to docs created off the main doc to use as backwards look-ups…etc.
This may not help you right now but for future reference, it is VERY useful.
Mike
Subject: RE: Modifying the @DocumentUniqueID
Hi Michael,
This is the problem im having. Record id pasted from another db so its original value has changed.
Really winding me up!
Subject: RE: Modifying the @DocumentUniqueID
What do you need that extremely ugly view for anyway?
I have a dark suspicion, but will keep that for a moment (as I might be very wrong).
Subject: Modifying the @DocumentUniqueID
Hey Viraj,
The UNID is a “special” value with a very specific purpose (a value that allows you to identify a specific document in the entire universe). It is put there by the platform and I think that changing it would be a really bad idea because you run the risk of destroying the uniqueness of the value by doing so. I have been writing notes applications for a long time and I have NEVER had occasion to mess with this value.
You may want to analyze your application and figure out another way to accomplish whatever it is that you are trying to do. If pasting docs in from other databases is presenting challenges, then consider solving the problem in the querypaste event in the database script.
Subject: Modifying the @DocumentUniqueID
You need to use Lotus Script to modify the document property…
LOTUSSCRIPT/COM/OLE CLASSES
UniversalID property
Example
Read-write. The universal ID, which uniquely identifies a document across all replicas of a database. In character format, the universal ID is a 32-character combination of hexadecimal digits (0-9, A-F).
The universal ID is also known as the unique ID or UNID.
Defined in
NotesDocument
Data type
String
Syntax
To get: unid$ = notesDocument.UniversalID
To set: notesDocument.UniversalID = unid$
Subject: RE: Modifying the @DocumentUniqueID
Hi graham,
so what your saying is if i write a lotuscript agent that says:
‘currentid’ = notesDocument.UniversalID
notesDocument.UniversalID = ‘newID’
and run it on the record the value will change??
Subject: RE: Modifying the @DocumentUniqueID
No, those two lines are examples on how to Read or to Update the property.
You will need some script with the line …
notesDocument.UniversalID = The_value_that_you_want_the_unID-to_be_set_to
and you’ll need to set the notesDocument to point to the document that you need to fix.
Subject: RE: Modifying the @DocumentUniqueID
Hi Graham,
Thanks for the advice, so would something like this be more appropriate:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim UNID, UniversalID As Variant
Set db = session.CurrentDatabase
Set doc = db.CreateDocument()
doc.UniversalID = Cstr(UNID)
notesDocument.UniversalID:="NeW_uNiQuE_iD"
Call doc.Save(True, True )
End Sub
Subject: RE: Modifying the @DocumentUniqueID
Yes …
Of course, you would be using an actual UNID as your value
While your code would create a document, you are not setting any fields. It may not show up in your database views.
You need to use doc, rather than notesDocument, as notesDocument has not been defined.
While that code will work, you are creating a new document rather than resetting an exisiting document, which I thought you were trying to do. You may want this agent to select a document in the database rather than creating a new one. (sample code below)
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set doc = db.GetDocumentByUNID( "a1bc0d239deaa94f8025740200402b46" )
doc.UniversalID ="a1bc0d239deaa94f8025740200402b47"
Call doc.Save( False , False )
End Sub
Subject: RE: Modifying the @DocumentUniqueID
Correct me, if I’m wrong, Graham, but modifying the UniversalID property of a document will always create a new document and leave the old one intact (even if the property is marked read-write). So, you would always have to change UniversalID, save the document and then delete the old document.
Subject: RE: Modifying the @DocumentUniqueID
Ah, yes it does … in which case you may want to add code to delete the old one once you’ve saved the new one.