Add or replace value to NotesItem via bean
Oct 27, 2014

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);
                nDoc.replaceItemValue(fieldname, oV);
            } else {
                nDoc.replaceItemValue(fieldname, inputValue);
        } catch (NotesException e) {
            // TODO Auto-generated catch block


Add a Comment 
More Actions 
Comments (1)

1 Patrick Kwinten commented Nov 18 2014 Permalink Recommendations 0
thanks for sharing!
This is an archive of my previous blog attachments are in the download control