Solved

Set the DocumentUnique ID of a document...

Posted on 2002-04-26
14
218 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
Comment Utility
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
Comment Utility
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
Comment Utility
:-)  I know you Jerrith !
0
 
LVL 1

Author Comment

by:oosterbaan
Comment Utility
Sorry....pushed the wrong button !!!!
0
 
LVL 8

Expert Comment

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

Expert Comment

by:Arunkumar
Comment Utility
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
Comment Utility
I'm just in a it's-nearly-weekend-mood.
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Author Comment

by:oosterbaan
Comment Utility
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
Comment Utility
No...you will be graded with a A, but not some more info (-:
0
 
LVL 1

Author Comment

by:oosterbaan
Comment Utility
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
Comment Utility
What more info you will be needing ?Let me know...

:-)
0
 
LVL 1

Author Comment

by:oosterbaan
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now