Examples: FolderReferences property
This agent creates a new document in the database, puts it into the view1, view2, and view3 folders, then prints out all folder references for each document with a count.
import lotus.domino.*;
import java.util.Vector;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
if (db.getFolderReferencesEnabled()) {
System.out.println("Folder references enabled");
}
else {
System.out.println("Folder references not enabled");
System.out.println("Enabling folder references");
db.setFolderReferencesEnabled(true);
}
Document doc = db.createDocument();
doc.appendItemValue("To", "Test Document Name");
doc.appendItemValue("Subject", "Test Document Subject");
doc.save(true, true, true);
System.out.println("Adding document to views");
doc.putInFolder("view1");
doc.putInFolder("view2");
doc.putInFolder("view3");
DocumentCollection dc = db.getAllDocuments();
doc = dc.getFirstDocument();
while (doc != null) {
Vector refs = doc.getFolderReferences();
for (int i = 0; i < refs.size(); i++) {
String ref = (String)refs.elementAt(i);
System.out.println(doc.getNoteID() +
" " + (i + 1) + " " + ref);
}
doc = dc.getNextDocument(doc);
}
} catch(Exception e) {
e.printStackTrace();
}
}
}