-1

Hi I'm new to Lotus Script

I want to run a Java Agent that access the Database to read views that are stored by forms.

I updated the code

Below is my code :

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
          // (Your code goes here) 
          Database db = agentContext.getCurrentDatabase();
          View view = db.getView("PetView");
          view.setAutoUpdate(false);
          view.setAutoUpdate(false);
          ViewEntryCollection vec = view.getAllEntries();
          System.out.println("Parent is " + 
            vec.getParent().getName());
          System.out.println("Number of entries = " + 
            vec.getCount());
          ViewEntry tmpentry;
          ViewEntry entry = vec.getFirstEntry();
          while (entry != null) {
            System.out.println("Entry is at position " + 
            entry.getPosition('.'));
            tmpentry = vec.getNextEntry();
            entry.recycle();
            entry = tmpentry;
          }
      } catch(Exception e) {
          e.printStackTrace();
       }
   }
}

My debug console O/P is :

    Parent is PetView
Number of entries = 8
Entry is at position 1
Entry is at position 2
Entry is at position 3
Entry is at position 4
Entry is at position 5
Entry is at position 6
Entry is at position 7
Entry is at position 8

Correct me If I'm wrong

Thanks .

theRoot
  • 571
  • 10
  • 33

2 Answers2

0

To get a database local, just use getdatabase without a servername.

Set db = notessession.getdatabase ("", "path\dbname.nsf")

adminfd
  • 1,006
  • 7
  • 14
0

Your code isn't even trying to access a view. You are accessing the collection containing all documents instead.

To access a view, you just need something like this:

View v = tempDb.getView("theViewNameOrAliasGoesHere");
Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41