I inherited an old Domino/DB2 agent that runs from 1 Db but populates other sales Dbs with the latest records/docs. It works as far as pulling in the latest records but is harsh in its approach! It seems to remove all instances and creates all new docs based on the latest records in DB2. The issue… it does not allow users to update Notes-only fields. e.g.a user opens the customer A document and wants to select a priority radio button. This priority radio button is Notes-side only and has no matching field in DB2. When the agent runs, it should “update” the customer A record vs. deleting and creating new doc OR create new docs if none detected in the Notes Db. The users need to be able to interact with the data… at the moment, the data is erased each night when the agent runs because docs are all deleted. It is a fairly large agent… needs some cleaning up and updates so that existing docs are updated in addition to new docs being created (e.g. new customers are created in DB2). I found where the doc was being set to “updated” but (for some reason) the doc.remove(true) is the result. Maybe I am missing something… is the same result if the task=“remove”.
note: it is a whopping 1644 lines (some white spaces + commented out comments/script). I think that 99% of it could remain the same. We just need to allow “update” to do its job vs. removing. This could be as simple as removing the doc.remove(true) from the update section. Anyone interested… just need some assistance… you can send email to dominoadmin@hotmail.com and include quote ($$$). I don’t expect anyone to do this one for free. It is just past me at this point… plate is full. Thanks team…
***here is where it sets to “update”
If (sql_cmcsnoText = doc_csno) Then
If (doc_csnm <> sql_csnm Or _
doc_longaddress <> sql_longaddress Or _
doc_zip4 <> sql_zip4 Or _
doc_terr <> sql_terr Or _
doc_fullname <> sql_pcnt Or _
doc_lastname <> wk_lastname Or _
doc_firstname <> wk_firstname Or _
doc_pupn <> sql_pupn Or _
doc_email <> sql_email Or _
doc_web <> sql_web Or _
doc_rep <> sql_repText Or _
Trim(doc_commentkey) <> Trim(sql_commentkey)) Then
task = "update"
End If
End If
***here is where it executes remove based on “update”
If task = “update” Then
Call doc.remove(True)
Set doc = New NotesDocument(db)
doc.Form = "Person"
doc.Type = "Person"
doc.DocumentAccess = "[UserModifier]"
doc.Logo = "beach"
doc.NameDisplayPref = "1"
doc.CompanyName = sql_csnm
doc.FullName = sql_pcnt
doc.LastName = wk_lastname
doc.FirstName = wk_firstname
doc.BusinessAddress = sql_address
doc.OfficeState = sql_stat
doc.OfficeStreetAddress = sql_cad1
doc.OfficeZIP = sql_zip4
doc.OfficePhoneNumber = sql_pupn
doc.MailAddress = sql_email
doc.WebSite = sql_web
Set richText = New NotesRichTextItem(doc, "Comment")
Call richText.AppendStyle(richStyle)
Call richText.AppendText(sql_commenttext)
'save plain text in plain text field, not just rich text field
doc.COMMENTKEY = sql_commentkey
doc.ShortName = sql_longaddress
doc.Location = sql_terr
doc.AltFullNameSort = "CUST2 " & sql_cmcsnoText & " Rep " & sql_repText
doc.cmcity = sql_city
doc.cmstate = sql_stat
doc.cmslyd = sql_cmslyd
doc.cmslly = sql_cmslly
Call doc.Save(True, False)
'get next doc
If validNotesRec = "true" Then
Set doc = nextDoc
If doc Is Nothing Then
validNotesRec = "false"
End If
End If
'get next sql
If result.IsEndOfData Then
validSqlRec = "false"
Else
result.NextRow
End If
End If
If task = "none" Then
'get next doc
If validNotesRec = "true" Then
Set doc = nextDoc
If doc Is Nothing Then
validNotesRec = "false"
End If
End If
'get next sql
If result.IsEndOfData Then
validSqlRec = "false"
Else
result.NextRow
End If
End If
Wend
Wend
con.Disconnect
End Sub
***just for interest’s sake… here is the remove script
If task = "remove" Then
Call doc.remove(True)
Print "Deleting Required Docs"
'get next doc
If validNotesRec = "true" Then
Set doc = nextDoc
If doc Is Nothing Then
validNotesRec = "false"
End If
End If