Domino Code Fragment

Code Name*
Generate Response Docs in LotusScipt
Date*
04/29/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.145.173.132
Description*
This view action will call a LotusScript agent to generate response documents on an entire database (all it's parent docs, that is). This formula can be found in the World Wide Country Database as a view action called "Add Fund To Countries". This view action first does a lookup on the Fund Library database. The user selects a new fund fromn this library and VIOLA! All the country documents will have a new fund doc (this is the response doc). This action calls the agent to do the actual creation of the response docs. The agent is hidden and is set to run on all docs in the view. The agent name is called Add Fund and it's event is set to INITIALIZE.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
theFLName := @PickList([Custom] ; "ftlns1/ftl/ftg" : "test\\wwcrfund.nsf" ; "A. Keyword List" ; "Entering Funds Library" ; "Please select the new fund:" ; 1 );
theFLNum := @DbLookup("" : "" ; "ftlns1/ftl/ftg" : "test\\wwcrfund.nsf" ; "A. Keyword List" ; theFLName ; 2 );
theGlobalCust := @DbLookup("" : "" ; "ftlns1/ftl/ftg" : "test\\wwcrfund.nsf" ; "A. Keyword List" ; theFLName ; 3 );
@SetEnvironment( "TheFLName" ; theFLName );
@SetEnvironment( "TheFLNum" ; theFLNum );
@SetEnvironment( "TheGlobalCust" ; theGlobalCust );
@Command([ToolsRunMacro] ; "(Add Fund)")


Now for the LotusScript Agent:

Sub Initialize
Dim session As New NotesSession
Dim db1 As NotesDatabase
'Dim db2 As New NotesDatabase( "" , "" )
Dim view As NotesView
Dim docA As NotesDocument
Dim docB As NotesDocument
Dim i As Integer
Dim theFLName$
Dim EnvTheFLNum$
Dim EnvTheGlobalCust$
Set db = session.CurrentDatabase
Set view = db.GetView( "2. Process Fund/Country\ b. Add Fund" )
'Call db2.Open( "" , "C:\\notes\\data\\templeton\\wwfund\\wwcrfund.nsf")

EnvTheFLName$ = session.GetEnvironmentString( "TheFLName" )

EnvTheFLNum$ = session.GetEnvironmentValue( "TheFLNum" )

EnvTheGlobalCust = session.GetEnvironmentString( "TheGlobalCust" )


Set docA = view.GetFirstDocument
While Not ( docA Is Nothing )

'create new docB using form "Fun"
Set docB = db.CreateDocument
docB.Form = "FUN"
Call docB.MakeResponse( docA )
docB.FUNCountry = docA.COUCountry
docB.FUNRegion = docA.COURegion
docB.FUNFundName = EnvTheFLName$
docB.FUNFundNo = EnvTheFLNum$
docB.FUNCustodian=EnvTheGlobalCust$
docB.FUNCode = docA.COUCode
Call docB.Save( True, True )
Set docA = view.GetNextDocument( docA )
Wend
End Sub