Today I thought I'd just share with you a little routine that I use when I want to make field level changes to a lot of documents without having to edit them. It's beginner stuff but I use it a lot.
What you need
A document, or group of documents with a field called DocNumber
A view where you can select those documents.
Creating the Agent
- Open Designer on the database (or template)
- Click on Shared Code then Agents
- Click on the button marked New Agent
- In the Properties box, give your agent a Name eg: Change Document Number
- It should be a Shared Agent
- In the Target Section, it should read All Selected Documents
- You don't need to change anything else in the properties box, so just close it.
- Now, in the intialize event of your Agent (just click on the word initialize and type in the box that appears).
- Type your code (or paste it from this page).
- When you've finished, Close the agent windows and choose YES to save your changes.
Dim NewSection As String
Dim Counter As Long
Dim ses As New notessession
Dim doc As notesdocument
Dim db As notesdatabase
Dim col As notesdocumentcollection
Counter = 0
NewSection = Trim$(Inputbox$("What is the name of the New Category?"))
If NewSection = "" Then
Print "You did not specify a category to move documents to. No documents moved."
Set db = ses.currentdatabase
Set col = db.unprocesseddocuments
While Not doc Is Nothing
doc.DocNumber = NewSection
Counter = Counter +1
Call doc.Save(True, True)
Print Trim$(Str$(Counter)) + " document(s) moved to category: " + NewSection
How to Use the Routine
Simply tag a whole heap of documents then click on Actions, then Change Document Number (from the Lotus Notes Menu). You'll be prompted for a new number and then it will change all the selected documents.
I use this routine a lot when I want to move documents from one section/category to another.