Add or replace value to NotesItem via bean
Oct 27, 2014
http://www.bleedyellow.com/blogs/DominoHerald/entry/october_27_2014_9_41_am?lang=en_us


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

 


Add a Comment 
Edit 
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 http://www.bleedyellow.com/blogs/DominoHerald attachments are in the download control