I am writing an agent that will insert the doc id.  This is the scenario :  I have 2 DBs, DBa, DBb...  In DBa, I have DocA which has a doclink to DocB of DBb.  In DBb, DocB also has a doclink to DocA.  I need to insert the doc id of DocA to DocB, and DocB to DocA.  Please provide code.  Thanks and regards.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Assuming that you have the handle for docA and DocB the following code will help you....


 Dim db1 As New notesdatabase("Server", "db1.nsf")
     Dim db2 As New notesdatabase("Server", "db2.nsf")
     Dim doc1 As notesdocument
     Dim doc2 As notesdocument
     Set doc1 = "Set the document 1"
     Set doc2 = "Set the document 2"
     Dim rtitem1 As notesrichtextitem
     Dim rtitem2 As notesrichtextitem
     Set rtitem1 = doc1.GetFirstItem("RichTextItem_Name_in_the_form_used_to_create_DocA")
     Set rtitem2 = doc2.GetFirstItem("RichTextItem_Name_in_the_form_used_to_create_DocB")
     Call rtitem1.AppendDocLink( doc2, "Any comments to this link")
     Call rtitem2.AppendDocLink( doc1, "Any comments to this link")
    Call doc1.Save(True,False)
    Call doc2.Save(True,False)          


Good Luck !


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MokMokAuthor Commented:
hi Arun...  what i need is to do is while running on DBa, i will sequentially go through all the docs there... e.g. docA, doc A have a doclink and using this doclink, i'll open it up then go to docB of DBb and get the doc id of docB then place it in the field for doc id that i created in docA of DBb.  and later i will also do the same for DBb.
Well, this is going to test your logic.
I can give you a hint on how to proceed and the rest is yours  :)

DocA in Db1 has a doclink to docB in Db2 right ?

Now this docA also has an extra field called $Links(notes generated).  This contains a junk like this :


This list can be accessed by using the following code

junk = docA.~$Links(0).

Out of the list the last line has the document id associated with it.  The unid is


This unique id is the unique id of the docB in DB2.

Derive this text from the above list using whatever logic u may think of and place it wherever you want.

The thing here is you need not go to the second db. you can finish off u'r task here itself.

Thats it.  Cool....

Good Luck !!!

MokMokAuthor Commented:
Hi Arun,

I am getting an error when I run the code :
junk = docA.~$Links(0) - error is "variant does not contain a container"...  Please enlighten...  Thanks and regards...
Check for the docA...That might not have got set.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.