I have the following agent which works well but I’d like to modify it so that it creates multiple documents at the same time.
Basically the user may select more than 1 employee name from a list, click a hotspot button and then the acknowledgement documents are recorded.
At this time I have to select one employee at a time. Can anyone advise me how to code this for more than 1 selection?
Thanks,
Angie
Sub Initialize
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIdocument
Set uidoc=ws.CurrentDocument
Dim targetDb As NotesDatabase
Dim targetDoc As NotesDocument
Dim sourceDoc As NotesDocument
Set sourcedoc=uidoc.document
Dim dateTime As NotesDateTime
Set targetDb = s.CurrentDatabase
Set targetDoc = targetDb.CreateDocument
targetDoc.Form = "Acknowledgment"
targetDoc.empName = sourceDoc.empCapture(0)
Set dateTime = New NotesDateTime(Format$(Now,"Long Date"))
Call targetDoc.ReplaceItemValue("Date", dateTime)
Call targetDoc.Save( False, False )
Subject: LotusScript agent?
Angie,
Details please? (you know me and wanting details)
How are you selecting the employee names? DialogList, Picklist? from a formula? from a field, from a view? from a form?
Subject: RE: LotusScript agent?
I have a multivalued listbox field called “lkpNon” which displays the employee names. The names are being pulled into the the field with the code below. Basically its being used to identify employees who have not yet responded to an e-mail.
a := @Sort(@Name([CN];@DbLookup(“”; “86256AF8:005FFFF2”;“Groups”; “Notes Users”;“Members”)));
b := @Sort(@Name([CN];@DbColumn(“”;“”;“Acknowledgement Report”;1)));
@Unique(@Trim(@Replace(A ; B; " ")))
With my current code I am able to select one name and create one acknowledgement. I’d love to be able to create 2 or more acknowledgements at one time. My scripting skills are still very poor.
Thanks, Angie
Subject: RE: LotusScript agent?
Angie,
You have got to leave of your disclaimer of script skills being poor and dive in. That is the only was I was able to learn it and I still have a lot to learn.
The script is very straightforward. Just put it in action button after the field.:
dim session as New NotesSession
dim db as NotesDatabase
set db=session.currentdatabase
dim ws as New NotesUIWorkspace
dim uidoc as NotesUIDocument
set uidoc=ws.currentdocument
dim doc as NotesDocument
set doc=uidoc.document
dim docAck as NotesDocument
dim vPeople as Variant
vPeople=doc.GetItemValue(“lkpNon”)
Forall p in vPeople
set docAck=db.CreateAck
’ populate the fields
call docAck.Makeresponse(doc)
Call docAck.save(true, false)
end forAll
end sub
Subject: LotusScript agent?
If you’re taking data from a document, set the field you want to read from (empCapture, in this case) as a multi-value field and use the NotesItem class:
Dim itm as NotesItem
Set itm = sourceDoc.GetFirstItem(“empCapture”)
Forall foo In itm.Values
targetDoc.empname = foo
’ and so on
End Forall
If you’d like to dispense with the document and just do this from a button, check the documentation on the PickListStrings class, which allows you to select from (among other things) an address dialog box.
Subject: LotusScript agent?
Thanks File Save,Yes, I do know that I have to teach myself LotusScript. Actually my skills have improved over the last couple of weeks. Things are beginning to click after using it. I still have a long way to go to be proficient.
Anyway, I’ve combined your code with mine but I’m getting an error message. “Variant does not contain an object.” I’m not sure I understand your for all code particularly the assigning of p. What do you want p to do?
As always, thank you for your help!
Sub Click(Source As Button)
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIdocument
Set uidoc=ws.CurrentDocument
Dim targetDb As NotesDatabase
Dim targetDoc As NotesDocument
Dim sourceDoc As NotesDocument
Set sourcedoc=uidoc.document
Dim dateTime As NotesDateTime
Set targetDb = s.CurrentDatabase
Dim vPeople As Variant
vPeople=doc.GetItemValue("lkpNon")
Forall p In vPeople
Set targetDoc = targetDb.CreateDocument
’ populate the fields
'Call targetDoc.Makeresponse(doc)
targetDoc.Form = "Acknowledgment"
targetDoc.empName = sourceDoc.empCapture(0)
Set dateTime = New NotesDateTime(Format$(Now,"Long Date"))
Call targetDoc.ReplaceItemValue("Date", dateTime)
Call targetDoc.Save( False, False )
End Forall
End Sub
Subject: RE: LotusScript agent?
Read the code you wrote angie and it will jump out at you. What I call doc, you call sourcedoc…