All,
Please pardon my ignorance, but I am trying to write a Java agent that
will read the values for five fields and than populate five other
fields on the same form with those values.
I know that this isn’t making much sense, but I am needing to write
this so that another developer can add in some other Java code
that he uses and than applies those values to the new fields.
I had gotten most of this example from a book written by Brian Benz.
Here is the question that I have:
I have the line of code below pulling the value for this field:
Item addressItem2 = NewMessage.getFirstItem(“address”);
Is this the correct way to add this value to a field titled jaddress2?
Item jaddress2 = NewMessage.replaceItemValue(“jaddress2”, address2);
Your comments much appreciated,
Jean
CODE EXAMPLE:
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
Database SupplierInfo = agentContext.getCurrentDatabase();
View Drafts = SupplierInfo.getView("(GEO Search)");
Document NewMessage = Drafts.getFirstDocument();
while (NewMessage != null) {
Item ProcessedItem = NewMessage.getFirstItem("Processed");
if (ProcessedItem.getValueString() != null); {
item addressItem = NewMessage.getFirstItem("address");
Item addressItem2 = NewMessage.getFirstItem("address");
Item city_State = NewMessage.getFirstItem("city_state");
Item state1 = NewMessage.getFirstItem("state1");
Item country1 = NewMessage.getFirstItem("country_1");
Item Processed = NewMessage.replaceItemValue("Processed", "1");
Item jaddress = NewMessage.replaceItemValue("jaddress", addressItem);
Item jaddress2 = NewMessage.replaceItemValue("jaddress2", address2);
Item jcitystate = NewMessage.replaceItemValue("jcitystate", city_State);
Item jstate1 = NewMessage.replaceItemValue("jstate1", state1)
Processed.setSummary(true);
NewMessage.save(true, false);
NewMessage = Drafts.getNextDocument(NewMessage);
}
}
} catch(Exception e) {
e.printStackTrace();
}
}
}