LOTUSSCRIPT/COM/OLE CLASSES
Examples: SavedData property
1. This script gets the SavedData document for the current agent script and sets its RunDate item to today's date.
Dim session As New NotesSession
Dim doc As NotesDocument
Set doc = session.SavedData
doc.RunDate = Date
Call doc.Save( True, True )
2. This agent script compares the maximum number of leads generated by a salesperson in the current week with the maximum number of leads generated last week. The script checks a view that contains Lead documents filled out by each salesperson. The first column in the view sorts the number of leads generated by each salesperson in descending order, so that the Lead document with the highest number of leads is first in the view. The NumLeads item on this document (which represents the maximum number of leads generated this week) is compared with the MaxLeads item on the SavedData document (which represents the maximum number of leads generated last week), and the Summary item is updated accordingly. The MaxLeads item on the SavedData document is then updated and both documents are saved.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc, agentDoc As NotesDocument
Dim d As Integer
Set db = session.CurrentDatabase
Set view = db.GetView _
( "This week's leads by salesperson" )
' first document in view has the most leads
Set doc = view.GetFirstDocument
Set agentDoc = session.SavedData
' the first time agent runs,
' there are no items on SavedData
' so set the MaxLeads item to zero
If Not( agentDoc.HasItem( "MaxLeads" ) ) Then
agentDoc.MaxLeads = 0
Call agentDoc.Save( True, True )
End If
d = doc.NumLeads( 0 ) - agentDoc.MaxLeads( 0 )
If ( d > 0 ) Then
doc.Summary = Abs( d ) & _
" more leads than last week's max."
Elseif ( d < 0 ) Then
doc.Summary = Abs( d ) & _
" less leads than last week's max..."
Else
doc.Summary = _
"You matched last week's max number of leads."
End If
' put this week's max leads onto SavedData
agentDoc.MaxLeads = doc.NumLeads
Call doc.Save( True, True )
Call agentDoc.Save( True, True )
End Sub
See Also
SavedData property
Glossary
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Glossary