Examples: Authors property

  1. This script prints the name of each author of a document. For example, if Ivan Ash created the document and Kate Gaston modified it, the script displays "Ivan Ash" and "Kate Gaston."
    Dim doc As NotesDocument
    '...set value of doc...
    Forall a In doc.Authors
      Messagebox( a )
    End Forall
  2. This script checks to see if a document has been modified within the last seven days -- if not, the script mails a reminder memo to the document authors. The script sends the value of doc.Authors directly to the Send method, since the method accepts an array of strings as its second parameter.
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim doc As NotesDocument
    Dim newDoc As NotesDocument
    Dim weekDateTime As NotesDateTime
    Dim modifiedDateTime As NotesDateTime
    Set db = session.CurrentDatabase
    '...set value of doc...
    Set weekDateTime = New NotesDateTime( "Today" )
    Set modifiedDateTime = New NotesDateTime( "" )
    Call weekDateTime.AdjustDay( -7 )  ' set to one week ago
    modifiedDateTime.LSLocalTime = doc.LastModified
    If weekDateTime.TimeDifference( modifiedDateTime ) > 0 Then
      Set newDoc = New NotesDocument( db )
      newDoc.Form = "Memo"
      newDoc.Subject = _
      "Reminder: please update your project plan"
      Call newDoc.Send( False, doc.Authors )
    End If
  3. You added a new role called TeamLeaders to a database and created a compose access list so that only TeamLeaders can compose Project Plan documents. You want to make sure that everyone who has been able to create and edit Project Plan documents in the past continues to be able to do so, so you write a script to enable the TeamLeader role for all authors of existing Project Plan documents.
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim acl As NotesACL
    Dim entry As NotesACLEntry
    Dim collection As NotesDocumentCollection
    Dim doc As NotesDocument
    Dim dateTime As New NotesDateTime( "12/01/94" )
    
    Set db = session.CurrentDatabase
    Set collection = db.FTSearch("Project Plan", 20)
    Set acl = db.ACL
    Set doc = collection.GetFirstDocument()
    While Not(doc Is Nothing)
      Call enablePeople( acl, "Team Leader", doc.Authors )
      Set doc = collection.GetNextDocument( doc )
    Wend
Sub enablePeople( acl As NotesACL, role As String, _
names As Variant )
  Dim entry As NotesACLEntry
  Forall n In names
    Set entry = acl.GetEntry( n )
    If ( entry.Level = ACLLEVEL_NOACCESS ) Then
      Set entry = New NotesACLEntry( acl, n, _
      ACLLEVEL_AUTHOR )
      Call acl.Save
    End If
    Call entry.EnableRole( role )
  End Forall
  Call acl.Save
End Sub