[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

Set the DocumentUnique ID of a document...

Is it possible to SET the documentUniqueID of a document ?

The reason I want to do this:

We have a database with documents in it that refer to each other using the documents Unique ID (doclinks). These doclinks are present in a FIELD.
I must split this database, so I have created a copy of this database, changed the functionality a bit and want to copy the documents into the new database (not all of the documents, only the documents that are needed in this new database)
Now all the doclinks arent't working anymore, because during a copy and paste action, the DocumentUniqueID of dcoment is changed.

I though to create a agent that get the value of the FIELD and reset the documentUniqueID to it's old value.

Is this possible ?

Greetings,

Bob
0
oosterbaan
Asked:
oosterbaan
  • 6
  • 4
  • 4
1 Solution
 
ArunkumarCommented:
YES its possible.... If you know the document unique IDS...

You can Set the documents unique ids using script. Recently HemanthaKumar wrote a script to set the document ids while copying the documents to another database here is that code.

Sub Initialize
    Dim s As New NotesSession
    Dim db, tdb As NotesDatabase
    Dim coll As NotesDocumentCollection
    Dim doc, cDoc As NotesDocument
    Set db = s.CurrentDatabase
    Server = db.Server   'target server
    FilePath = "**********target Database Path********"
    Set tdb = New NotesDatabase(Server,FilePath)     ' TargetDatabase
    Set coll = db.UnprocessedDocuments
    Set doc = coll.GetFirstDocument
    While Not doc Is Nothing
         Gosub CopyToTargetDB
         Set doc = coll.GetNextDocument(doc)
    Wend
    Exit Sub
CopyToTargetDB:
    Set cDoc = tdb.CreateDocument
    Call doc.CopyAllItems(cDoc)
    cDoc.UniversalID = doc.UniversalID
    Call cDoc.Save(True,False)
    Return
End Sub

I know you are looking for something different. I am pasting this so that you get an idea on how to set the doc id to a document. Got it ?

More details just post a comment...

Best Wishes!
Arun.

0
 
Jean Marie GeeraertsCommented:
I don't like that code, because there's a GoSub command in there. Yikes, bad programming, Arun :-)

In stead use a subroutine or in this case, just put the code inside the loop, since it's really not that complicated.

Just wanted to write a comment here to annoy Arun. >:-D
0
 
ArunkumarCommented:
:-)  I know you Jerrith !
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
oosterbaanAuthor Commented:
Sorry....pushed the wrong button !!!!
0
 
Jean Marie GeeraertsCommented:
O Bob, Ouch, that's gotto hurt :-)
ROTFL
0
 
ArunkumarCommented:
You mean the grading of C is the wrong button ? You can request the community support to give an "A" for me if you wish...

:-)
Jerrith did you fall down to the floor ?
0
 
Jean Marie GeeraertsCommented:
I'm just in a it's-nearly-weekend-mood.
0
 
oosterbaanAuthor Commented:
What I can do is to create a agent in the "old" database that will add a field in the documents with the DocumentUniqueID in it. Then copy the documents to the new database and run a agent that will copy the value of this field as DocumentUnique ID....

Isn't this a great idea ?

Isn't this a simple agent....? (not for me, since i have no knowlegde of lotusscript)

Greetings,

Bob
0
 
oosterbaanAuthor Commented:
No...you will be graded with a A, but not some more info (-:
0
 
oosterbaanAuthor Commented:
Try it agin, but now slowly....

No...you will be graded with a A, but NEED some more info *LOL*
0
 
ArunkumarCommented:
What more info you will be needing ?Let me know...

:-)
0
 
oosterbaanAuthor Commented:
Please, show me the LotusScript code for this ?

Read the value from the FIELD in the form and put this as documentUIniqueID

Thx...
Greetings,

Bob
0
 
Jean Marie GeeraertsCommented:
Hey Bob,
Run the agent in your new database on all documents in the database and modify the code Arun gave as follows:

Sub Initialize
   Dim s As New NotesSession
   Dim db As NotesDatabase
   Dim coll As NotesDocumentCollection
   Dim doc As NotesDocument

   REM Get the documents to be processed
   Set db = s.CurrentDatabase
   Set coll = db.UnprocessedDocuments

   REM Loop through all documents in the collection
   Set doc = coll.GetFirstDocument
   Do While Not doc Is Nothing
        REM Set the documents UniqueID to the value found
        REM in the field 'NameOfTheField'.
        REM As you probably know, you always have to use an
        REM index to reference to the value of a field, that's
        REM what the (0) after the name of the field is for.
        doc.UniversalID = doc.NameOfTheField(0)
        Call doc.Save(True,False)
        Set doc = coll.GetNextDocument(doc)
   Loop
End Sub

Have a nice weekend !

JM
0
 
oosterbaanAuthor Commented:
Hi JM,

This didn't worked... When I start the agent, it creates a copy of the document with the new DocID..Proberbly my fault (-:

Can the agent be much more simple, so I can understand what I'm doing...

Can't I create a agent that whill run on the selected document that will only do something like this ?


       doc.UniversalID = doc.NameOfTheField(0)
       Call doc.Save(True,False)
     
I have created this "simple" agent, but Error messages occur (ofcourse) about Variants and Objects (-: not defined....

What do I need to define to let this simple agent run ?

Thanks,

Bob


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now