Domino Code Fragment

Code Name*
Agent to Lookup and update another database
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.218.70.93
Description*
With a scheduled agent, go through database A and match a field on a document with a field from another document in a different database B. If there is a match, update a couple of fields in database B from information on the document from database A.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

Sub Initialize
Dim session As New notessession
Dim db As notesdatabase
Set db = session.CurrentDatabase
Dim dbcfp As notesdatabase
Set dbcfp = New NotesDatabase( SERVER NAME, DB NAME WHERE YOU WANT TO MAP )
Dim doc As notesdocument
Dim doc1 As NotesDocument
Dim view As NotesView
Dim view1 As NotesView
Set view = db.GetView("Crtl_Number")
Set view1 = dbcfp.GetView("ID")
Dim cdpflag As Variant
Dim rutitle As Variant
Dim ruphase As Variant
Dim item As NotesItem
Dim item1 As NotesItem
Dim doc2 As NotesDocument
On Error Resume Next


Set doc = view.GetFirstDocument
Do While Not (doc Is Nothing)
cdpflag = doc.CFP
rutitle = doc.DocTitle
ruphase = doc.Status(0)
rudatepub = doc.DatePublic


Set doc2 = view1.GetDocumentByKey(cdpflag)

If ( doc2 Is Nothing ) Then

Else
Set item = doc2.ReplaceItemValue("Title", rutitle)
Set item1 = doc2.ReplaceItemValue("Actual_Dt_Public",rudatepub)
Call doc2.Save (True, True)
Call view1.Refresh


End If

Set doc = view.GetNextDocument(doc)

Loop

End Sub