Mass Update Agent

This agent can be run in any database without any modifications. Just copy in
the dialogbox form and the agent and you are ready to go. This agent will act
on selected documents. When run the agent will get a count of how many forms
are in the database and dimension an array to that count. Then it will cycle
through the selected documents and store the different form types in the array
(no duplicates). Then it will save those form types in an environment
variable. Then the user will be prompted with a dialog box that gives a
combobox list of the different types of forms for selected documents. The user
then selects a form. Then the user is prompted the same dialogbox except this
time the values are that of all fields that are on that form type. The user
then selects a field. Then the user is prompted for a new value. Finally the
agent will run through the document collection and update every documents field
that uses that form with the new user supplied variable.
This agent was created jointly by Al Wiesner and Paul Asadoorian.
Create a dialog box with the following a field called "ChoiceBox" that is a
combobox and type of editable. The default value should be the following

Choice := @TextToNumber(@Environment("DispWhat"));
@If(Choice = 1; @Trim(@Explode(@Environment("FormArray"); ":"));
@Trim(@Explode(@Environment("FieldArray"); ":")))

Agent Script:

Dim curDB As NotesDatabase
Dim FormArray() As String
Dim FieldArray() As Variant

Sub Initialize
Dim s As New NotesSession
Dim curColl As NotesDocumentCollection
Dim FormName As String
Dim FieldName As String
Dim FormCnt As Integer
Dim DispWhat As Integer

'get a count of the number of forms in the database to set the array
FormCnt = GetFormCount

'get selected documents
Set curDb = s.CurrentDatabase
Set curColl = CurDB.UnprocessedDocuments


'get a non-duplicate array of form types for selected documents
'returns a 1to pass to PromptDialog so it will show the form dialog box
DispWhat = GetForms(curColl, FormCnt)

' prompt with list of forms to edit by
FormName = PromptDialog(DispWhat)

If FormName = "Exit" Then
Exit Sub
End If
'get an array of all fields that are on the selected form type for selected
'returns a 2 to pass to PromptDialog so it will show the fields dialog box

DispWhat = GetFields(FormName)

'prompt with a list of fields to edit
FieldName = PromptDialog(DispWhat)

If FormName = "Exit" Then
Exit Sub
End If
'edit the doc by form and mass change all documents by FormName in the document
Call EditDocs(FormName, FieldName, curColl)

Goto GetAnotherFormName

End Sub

Function GetFormCount As Integer
Dim session As New NotesSession
Set curDB = session.CurrentDatabase
Dim cnter As Integer

Forall form In curDB.Forms
cnter = cnter + 1
End Forall

GetFormCount = cnter
End Function

Function GetForms(curColl As NotesDocumentCollection, FormCnt As Integer) As
Dim curDoc As NotesDocument
Dim S As New NotesSession
Dim FirstTime
FirstTime = True
Dim ArrayPos As Integer
Dim cnt As Integer
Dim i As Integer
Dim value As Variant
Dim value2 As Variant
Dim compare As Integer
Dim value1 As String
Dim EnvirString As String
Dim J As Integer
Redim FormArray(FormCnt) As String

Set curDoc = curColl.GetFirstDocument

While Not(curDoc Is Nothing)
If FirstTime Then
value = curDoc.GetItemValue("form")
value1 = value(0)
FormArray(0) = value1
FirstTime = False
ArrayPos = ArrayPos + 1
Goto AfterFirst
End If

For i = 0 To FormCnt
value = curDoc.GetItemValue("form")
value1 = value(0)
If value1 = FormArray(i) Then
Goto AfterFirst
End If

If i = FormCnt Then

If value1 = FormArray(i) Then
Goto AfterFirst
End If
value = curDoc.GetItemValue("form")
value1 = value(0)
FormArray(ArrayPos) = value1
cnt = cnt + 1
ArrayPos = ArrayPos + 1
End If
Next i

Set curDoc = curColl.GetNextDocument(curDoc)
FirstTime = True

For J = 0 To Cnt
If FirstTime Then
EnvirString = FormArray(J)
FirstTime = False
Goto AnotherJ
End If
'create a colon delimited string to save in an environment variable to be
called by
'the dialog box
EnvirString = EnvirString & ":" & FormArray(J)
Next J

Call S.SetEnvironmentVar("FormArray", EnvirString, False)
GetForms = 1
End Function

This was last published in November 2000

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...