|
|
|
|
|
|
|
|
|
|
|
|
|
|
A reusable agent to change field values on documents (continued)
Sub CreateFieldChoiceList
'--Dim the local variables
Dim form As NotesForm
Dim i As Integer
i = 0
'--Get the form that the first selected document uses
Set form = currentDB.GetForm ( formName )
'--Build an array of the field names from the selected document
Forall item In selectedDoc.Items
Redim Preserve fieldNames(i)
'--If the field name begins with a "$", then skip it
If ( Left ( item.Name, 1 ) <> "$" ) _
And ( item.Type <> RICHTEXT ) _
And ( item.Name <> "UNID" ) _
And ( item.Name <> "FORM" ) Then
fieldNames(i) = item.Name
i = i + 1
End If
End Forall
'--Sort the fields by name before you present them as choices to the user
fieldChoiceList= SortArray ( fieldNames )
End Sub
|
Sub ConfirmChange
'--Dim the local variables
Dim confirm As Integer
'--Ask the user if they are sure they want to make the change
confirm = Msgbox ( "Are you sure you want to change the " & Cstr ( fieldChoice ) & _
" field to """ & newValue & """ for all selected documents?", _
MB_OKCANCEL, "Confirm Change:" )
'--Set the value of the continue variable to either "Yes" or "No"
If ( confirm = IDOK ) Then
continue = "Yes"
Else
continue = "No"
Exit Sub
End If
End Sub
|
Function SortArray ( inarray As Variant ) As Variant
'--This SortArray function can be put into a script library along with the
'--Swap sub and called from there
Dim i%, j%, max%
Dim array As Variant
array = inarray
max% = Ubound(array)
For i% = 0 To max% - 1
For j% = i% + 1 To max%
If array(i%) > array(j%) Then
Swap array(i%), array(j%)
End If
Next
Next
SortArray = array
End Function
|
Sub Swap ( v1 As Variant, v2 As Variant )
'--This Swap sub can be placed in a script library along
'--with the SortArray function and called from there
Dim v As Variant
v = v1
v1 = v2
v2 = v
End Sub
|
Conclusion The possibilities for customizing this agent are many. You can modify it so that you further narrow down the fields and even types of fields that you allow the user to change. You can make it an agent that worms its way through all of the documents in a database changing any fields that have a specific value that you specify. Or you can use it as is and save yourself from having to constantly create simple agents that change specific fields.
It's been a while since I've done a how-to article and I've definitely had fun doing this one. If you have any comments or questions, you can reach me at my new company at dan_velasco@idg.com. And, for a sample database containing all of the code contained in this article, go to http://dan.velasco.com.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
Sophisticated Meets Simple For Document Management
Share. Control. Manage.
Documents, emails, and content in the context of how work is done.
Native to Lotus Domino. The User Experience unseen for Lotus Domino.
Do more with less. Really.
See the possibilities Docova unleashes for Lotus Domino. |
-- Advertisement --
Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.
Register by April 10 to save $200. |
|
|
|
|
|
|
|
|
|
|