It is necessary to add data to all the existing documents. An agent can be used to automate this process.
Agents are stand-alone (do not reside on forms or views) programming elements that can be:
- Scheduled (for example, to run at certain times)
- Activated manually by the user
- Activated programmatically
The purpose of this agent is to set a value for the category
item in documents selected by the user. This is useful both for assigning initial category values and changing category values.
The agent is coded in the Notes
™. However, exposure to the formula language is useful for form and view design.
Parent topic: Your first view
- In the Application Navigator, expand Code.
- Right-click on Agents and select New Agent.
- In the New Agent dialog, do the following:
- Name the agent Set category red.
- Change the type to Formula.
Note: Don't forget to do this. The default is LotusScript®. If you are moving on to XPages, learning LotusScript is not necessary.
- Click OK.
- Review the agent properties as follows:
- In the agent edit pane, right-click and select Agent Properties.
- For Runtime properties, leave Trigger as On event and Action menu selection. Leave Target as All selected documents.
This means that the agent will be visible to the user on a menu and will be applied to every document currently selected by the user.
- Close the dialog.
- Enter the following formula in the programming editor pane and save the code:
FIELD category := "red";
The first statement assigns a value to a field. The second statement means that the formula will be applied to all documents for which the agent is destined (in this case, all selected documents).
Take care with case. Ensure that literals in the code exactly match the available choices in the user interface.
When you type the formula, you can omit the second statement. SELECT @All
is automatically appended to a formula of this type by default.
- Right-click the agent and select Copy. Right-click Agents and select Paste. Do it again so that you have the original agent and two copies.
- Open each copy. Change the names and the code to set the category field to green and blue.
- Open the application in Notes.
Select two documents and click Actions
-> Set category red
- Set half the remaining documents to green and half to blue.
- Open the documents to ensure they are correctly set.