 |
Return to article
Sub Initialize
REM Code Name = Send Memo of Selected DocLinks to Group(s)
REM LS Program Type = Manual Server Agent
REM Database Name = DevCodeLibnsf.nsf
REM Date = 10-05-2001
REM Company = Lotus Development Corp.
REM Author = Don Russell
REM Rev = A
REM Purpose = This agent is called by an action within the
"03. Administration \ 02. All by Doc Unique #" view
REM Its purpose is to create doclinks with document Title information from
selected documents
REM It creates a memo with the doclink and Title information and mails this
information to the runner of the agent.
'
On Error Goto GeneralErr
Dim agentLog As New NotesLog("Agent log")
Call agentLog.OpenAgentLog
Dim s As New notessession
Dim db As notesdatabase
Dim doc As notesdocument
Dim dhandle As notesdocument
Dim whatnew As notesdocument
Dim collect As notesdocumentcollection
Dim view As notesview
Dim rtitem As notesrichtextitem
Dim itemn As notesitem
Dim itm As notesitem
Dim items As notesitem
Dim MyDocNum As String
Dim TDBURL As String
'
Dim ViewS As Notesview
Dim SysPdoc As Notesdocument
Dim MyMvMailList As Variant
Dim MySMailList() As String
Dim UPB As Integer
Dim MyBeginComment As String
Set db=s.currentdatabase
Set viewS=db.getview("SP") ' View of System Parameter Document
Set SysPdoc=viewS.getfirstdocument
Set itm = SysPdoc.GetFirstItem("TemplateMailList")
MyMvMailList = SysPdoc.GetItemValue("TemplateMailList")
' MyMailList obtained from System Parameter Document
UPB = Ubound(MyMvMailList)
MyBeginComment = SysPdoc.BeginComment(0) ' MyBeginComment
obtained from System Parameter Document
TDBURL = SysPdoc.DBURL(0) ' Get This DB URL from Sys Par Doc
' Equate to a Dynamic String Array that is Re-Dimensioned for the
number of elements
Dim It As Integer
Redim MySMailList (UPB) As String
For It = 0 To UPB
MySMailList(It) = Cstr (MyMvMailList(It))
Next
'
' Dim j As Integer
' For j = 0 To i ' For debugging. To display the recipient list...
' Messagebox "recipient(" & j & "): " & MySMailList(j)
' Next
'
Set view=db.getview("(DUN)")
Set collect=db.unprocesseddocuments
'Create the doc
Set whatsnewuser=db.createdocument
whatsnewuser.form="memo"
Set rtitem = New NotesrichTextItem(whatsnewuser, "Body")
Set itemn = New NotesItem(Whatsnewuser, "Name", MySMailList)
' Make sure user has selected documents
' If user has selected no documents the currently highlighted document
will be looked at as being selected,
' so we should prompt the user to confirm whether the single document
selection is correct.
' Build the doc.
' Loop through selected docs collection, make a doclink and append the
doc number and title field info.
'==================================================
Call Rtitem.appendtext(MyBeginComment & Chr(10) & Chr(10) )
Call Rtitem.appendtext(Chr(13))
Call Rtitem.appendtext("Developer's Template Library DB Browser Access:")
Call Rtitem.appendtext(Chr(13))
Call Rtitem.appendtext(TDBURL)
Call Rtitem.appendtext(Chr(13) + Chr(13))
'===================================================
' Note: We use the GetFirst and GetNext methods as they are quicker than
using GetNth
Set doc=collect.getfirstdocument
Cat = doc.TempTitle(0)
Set items = New NotesItem(Whatsnewuser, "Subject", Cat)
items.issummary=True
'====================================================
For i = 1 To collect.count
If doc.isresponse Then Goto getnextdoc
' Get handle to document in the "03. Administration \ 02. All by
Doc Unique #" - for proper doclink creation
Set dhandle=view.getdocumentbykey(doc.DocUniqueNumber(0))
MyDocNum = doc.DocUniqueNumber(0)
Call Rtitem.appendtext(+ Chr(13) + Chr(10) + doc.TempTitle(0) &
Chr(13) & "Doc # " & doc.DocUniqueNumber(0) & " ")
Call Rtitem.appenddoclink( dhandle, "Database '" & db.title & "',
View '" & view.name & "', Document '" & doc.TempTitle(0))
GetNextDoc:
Set doc=collect.getnextdocument(doc)
Next
' Send the doc
whatsnewuser.subject="Template in Dept Template Warehouse DB: "
& whatsnewuser.subject(0)
Call whatsnewuser.send(False, MySMailList)
Call agentLog.LogAction( "Sent Template Doc # " + MyDocNum)
Call agentLog.LogAction( "Sent Template Doc Memo to the following: ")
For It = 0 To UPB
Call agentLog.LogAction(MySMailList(It))
Next
Goto TEnd
GeneralErr:
Call agentLog.LogAction( "Unique Doc Numeber of last Doc = "
+ MyDocNum)
Call agentLog.LogAction( "See the 03. Administration \ 02. All by Doc Unique
# view to lookup above Document Unique # ")
Call agentLog.LogAction( " Error # = " + Str(Err))
Call agentLog.LogAction(" Error String = " + Error$)
Call agentLog.LogAction( " Error Line # = " + Cstr(Erl))
Call agentLog.LogAction(" Report this error to your DB Designer with the
following information ")
Call agentLog.LogAction(" Agent Type and Name - Manual - Send Memo of
Selected DocLinks to Dept Group")
Call agentLog.LogAction(" Database Title = " + db.Title)
Call agentLog.LogAction( " Database Filename = " + db.Filename)
Call agentLog.LogAction( " Database Directory Path = " + db.Filepath)
Print "Error - Agent Aborted - Check Manual Agent - Send Memo of Selected
DocLinks to Dept Group - Log for more Detail"
Resume TEnd
TEnd:
Call AgentLog.Close
End Sub
|
Return to article
|  |
|