Lesson learned in ReplaceItemValue vs NotesItem


In a project I am working on I am modernizing a Domino application with XPages and JAVA MVC. To support the workflow in the application a “main” document must have at least 1 approved “sub” document for 9 mandatory areas. These “sub” documents appear then in a Notes view and an agent is keeping the overview if all 9 areas have approved documents .

The selection formula for this view is something as followed:

SELECT Form=”formA” & status=”40″ & notAuthorized = “”


To add a field to a document I normally use ReplaceItemValue as described in the XPages wiki.  The Help in Designer says about this method:

Replaces all items of the specified name with one new item, which is assigned the specified value. If the document does not contain an item with the specified name, this method creates a new item and adds it to the document.

So that sounded that I was good to go. Except… the documents created by my script did not appear in my view.

Document properties

When I compared the documents with ScanEZ / looked at the Document Properties tab / created on output via Document Viewer I could not find an explanation why the documents should not match the View selection formula 😕

Modifying the selection formula to something outrageous like

SELECT Form=”formA” & status=”40″ & notAuthorized != “SOMEOUTRAGEOUSCONDITION”

resulted that the documents appear in the view.

But I would rather like to keep the current data model of the View as is in place so the current code/UI could not become disturbed in any way.

Notes Item

Then I decided to change my code from

doc.replaceItemValue(“notAuthorized”, “”);


Item textItem = doc.replaceItemValue(“notAuthorized”, null);



and I noticed the documents appear now in the Notes View.

When I compare the two methods in the replaceItemValue method the field notAuthorized is empty but has a data-length of 1. In the Item method the field is also empty BUT the data-length is 0.

So something is added to the field. But what?


First I thought perhaps it’s due to the Summary property but in both methods the Summary property set (at least it looks like that).

Here is some more information from Designer Help:


The IsSummary property of the new item defaults to true, which means that the item value can be displayed in a view or folder.

So I am wondering if the replaceItemValue (in Java) is properly setting this property or maybe not?


PutInFolder method – does not allocate my private folder

For a search function in an application I would like to place results in a private (desktop) folder. For that I created a shared, private on first use folder. I do not want to have a folder residing on the server side because I fear this will blow up the view indexes. It is also a restriction in our environment (create personal folders is by default disabled).

The private folder will be created when opening the search form which is embedded in a split frame (on top the search form, in the bottom the folder).

However when I use the PutInFolder method, this tries to place result documents in the first folder it finds, in this case the shared, private on first use folder.

Call srchDoc.PutInFolder(“$fld-searchresults”)

This is also confirmed via a warning message:

If I look in design it seems the method wants to place the documents in the first folder it finds:


On the other hand, when I have a document opened the AddToFolder formula has no problem with finding the correct folder:



My question is quiet simple:

How can I make sure that my code places the documents in the private folder and not the shared one?