JAVA/CORBA CLASSES


Examples: computeWithForm method
Assume that the Subject field on the "Main Topic" form contains the following validation formula:

@If( Subject = ""; @Failure( "You must enter a Subject" ); @Success )

The following agent as it stands does not save the document. If the replaceItemValue line for Subject is uncommented, the agent saves the document.

import lotus.domino.*;
public class JavaAgent extends AgentBase {
 public void NotesMain() {
   try {
     Session session = getSession();
     AgentContext agentContext = session.getAgentContext();
     // (Your code goes here)
     Database db = agentContext.getCurrentDatabase();
     Document doc = db.createDocument();
     doc.replaceItemValue("Form", "Main Topic");
//      doc.replaceItemValue("Subject", "Subject of document");
     doc.replaceItemValue("Body", "Text of document.");
     if (doc.computeWithForm(false, false)) {
       System.out.println("Saving document ...");
       doc.save(true, true); }
     else
       System.out.println("Document not saved.. no subject");
   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also