Solved

Set the DocumentUnique ID of a document...

Posted on 2002-04-26
14
225 Views
Last Modified: 2013-12-18
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
Comment
Question by:oosterbaan
  • 6
  • 4
  • 4
14 Comments
 
LVL 9

Expert Comment

by:Arunkumar
ID: 6970826
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
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6970870
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
 
LVL 9

Accepted Solution

by:
Arunkumar earned 50 total points
ID: 6970897
:-)  I know you Jerrith !
0
Independent Software Vendors: 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!

 
LVL 1

Author Comment

by:oosterbaan
ID: 6971077
Sorry....pushed the wrong button !!!!
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6971121
O Bob, Ouch, that's gotto hurt :-)
ROTFL
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 6971131
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
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6971163
I'm just in a it's-nearly-weekend-mood.
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6971176
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
 
LVL 1

Author Comment

by:oosterbaan
ID: 6971183
No...you will be graded with a A, but not some more info (-:
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6971186
Try it agin, but now slowly....

No...you will be graded with a A, but NEED some more info *LOL*
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 6971375
What more info you will be needing ?Let me know...

:-)
0
 
LVL 1

Author Comment

by:oosterbaan
ID: 6972309
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
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 6972950
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
 
LVL 1

Author Comment

by:oosterbaan
ID: 6973115
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Migration: Lotus Notes to Exchange 2013 10 339
Domino Server 2 84
Migration Lotus to Exchange 2016 4 210
LotusScript: Merge Data to Word File 22 112
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question