I'm working on a new app, and in the workflow I write to a number of status fields. The below method checks to see if the NotesItem is already there, and if so, appends a value to it. If it is not, it creates the new NotesItem and puts the first value in. It does not really seem to work if I pass a vector in as the inputValue. I may work on that in a bit where this method checks to see if the inputValue is a vector, and if so adds each element of that vector in. But that's not been an issue for me yet, so I've not done it, but will be on my list. This is a simple method, but it may be useful to someone. public void newOrAppendItemValue(String fieldname, Object inputValue, Document nDoc) {
//object is valid for the value of an item
//call as: newOrAppendItemValue("statusHistory", "Text or other to add", nDoc);
try {
if (nDoc.hasItem(fieldname)){
java.util.Vector oV = nDoc.getItemValue(fieldname);
oV.addElement(inputValue);
nDoc.replaceItemValue(fieldname, oV);
} else {
nDoc.replaceItemValue(fieldname, inputValue);
}
} catch (NotesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} Cheers,
Brian
|