I needed to be able to copy fields from a saved document to the document on screen. This was in our HR system, where we set objectives and KPI's for bonuses.
I made life easy for myself by naming all of the fields that were required for copying "KPI_xxx". The code below take this into account.
Sub Click(Source As Button)
Dim workspace As New NotesUIWorkspace
Dim picklist As Variant
Dim strDocid As String
Dim s As New NotesSession
Dim currdb As NotesDatabase
Dim doc As NotesDocument
Dim uidoc As NotesUIDocument
Dim DocUIDoc As NotesDocument
Set currdb = s.CurrentDatabase
picklist = workspace.PickListStrings( _
PICKLIST_CUSTOM, _
False, _
currdb.server, _
currdb.filepath, _
"(Aim For Excellence)", _
"Document selection", _
"Please select one document.", _
6 )
Forall plist In picklist
strDocid = plist
End Forall
Set doc = currdb.GetDocumentByUNID(strDocid)
Set uidoc = workspace.CurrentDocument
Set DocUIDoc = uidoc.Document
uidoc.AutoReload = False
Forall i In doc.Items
If Left(i.name,3) = "KPI" Then
Set item = i.CopyItemToDocument( DocUIDoc, i.name )
End If
End Forall
Call uidoc.Reload
uidoc.AutoReload = True ' restore default
Call uidoc.RefreshHideFormulas
End Sub
No comments:
Post a Comment