Examples: FolderReferences property (NotesDocument - LotusScript®)

The following script creates a new document in the database, puts it into view1, view2, and view3 folders, then prints out all folder references and a count for each document.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = session.CurrentDatabase
If(db.FolderReferencesEnabled) Then
  Messagebox ("Folder references enabled")
Else
  Messagebox("Folder references are not enabled")
  Messagebox("Enabling folder references")
  db.FolderReferencesEnabled = True
End If
Set doc = db.CreateDocument
If Not(doc Is Nothing) Then
  Call doc.AppendItemValue("To", "Test Document Name")
  Call doc.AppendItemValue("Subject", "Test Document Topic")
  Call doc.Save(True, True)
  Messagebox ("Adding document to views")
  doc.PutInFolder("view1")
  doc.PutInFolder("view2")
  doc.PutInFolder("view3")
  Call doc.Save(True, True)
End If
Dim doccoll As NotesDocumentCollection
Set doccoll = db.AllDocuments
Set doc = doccoll.GetFirstDocument
While Not(doc Is Nothing)
  i = 0 
  Forall FolderReference In doc.FolderReferences
    i = i+1
    Print doc.noteid, "", i, "", FolderReference
  End Forall
  Set doc = doccoll.GetNextDocument(doc)
Wend