Search DominoPower's 11,441 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
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.


« Previous  ·  1  ·  2  ·  3  ·  4  ·  Next »
Other articles you might like
Home > Lotus Technologies > Notes (84 articles)
   A walk down Memory Lane with Lotus Notes
   An application for scanning physical mail and distributing it virtually
   Managing Notes deployments with Teamstudio Build Manager
Home > Lotus Technologies > LotusScript (64 articles)
   When the debugger won't debug hidden code that isn't hidden
   What to do if the LotusScript debugger won't single-step over code
   Little known traps about Lotus Notes fields
Home > Tips & Techniques (102 articles)
   More about Domino log files
   Why your log.nsf might not be purging properly
   A faster way to repair corrupted server files
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
2010: A Lotusphere of change
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: The iPad defenders have spoken
David Gewirtz Online: CNN commentary and analysis
OutlookPower: More about disappearing text
-- 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.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login