« Return to the main article
i have tried the below code to create a contact using agent, the getting the msg like doc has saved but the created doc is not displayed in the Address book- contacts list can u help me how to insert contact.
Here is the agent that creates a new document;
import lotus.domino.*; import javax.swing.*; import java.awt.*;
public class JavaAgent extends AgentBase {
public void NotesMain() { String fname; String lname; try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); Database db = agentContext.getCurrentDatabase(); Document doc = db.createDocument(); fname = JOptionPane.showInputDialog("Enter your first Name"); lname = JOptionPane.showInputDialog("Enter your last Name"); String fullName = fname + " "+ lname; String welcomeMsg = "Your document will now be saved " + fullName; JOptionPane.showMessageDialog(null, welcomeMsg); doc.replaceItemValue("Fname", fname); doc.replaceItemValue("Lname", lname); doc.replaceItemValue("Form", "Names"); doc.save(); JOptionPane.showMessageDialog(null, "Your document was saved"); // (Your code goes here)
} catch(Exception e) { e.printStackTrace(); } } }
i have tried the below code to create a contact using agent, the getting the msg like doc has saved but the created doc is not displayed in the Address book- contacts list can u help me how to insert contact.
Here is the agent that creates a new document;
import lotus.domino.*; import javax.swing.*; import java.awt.*;
public class JavaAgent extends AgentBase {
public void NotesMain() { String fname; String lname; try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); Database db = agentContext.getCurrentDatabase(); Document doc = db.createDocument(); fname = JOptionPane.showInputDialog("Enter your first Name"); lname = JOptionPane.showInputDialog("Enter your last Name"); String fullName = fname + " "+ lname; String welcomeMsg = "Your document will now be saved " + fullName; JOptionPane.showMessageDialog(null, welcomeMsg); doc.replaceItemValue("Fname", fname); doc.replaceItemValue("Lname", lname); doc.replaceItemValue("Form", "Names"); doc.save(); JOptionPane.showMessageDialog(null, "Your document was saved"); // (Your code goes here)
} catch(Exception e) { e.printStackTrace(); } } }