• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:


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.
  • 3
  • 2
1 Solution
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 !

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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now