I have a multivalue field on my document that I would like to remove a value based on the value.
I came up with this:
var doc:NotesDocument = rowData.getDocument();
var item:NotesItem = doc.getFirstItem("ValidProjects");
var a:Array = item.getValues()
for (var v in a)
dBar.info("Before removed V=" + v );
removeFromArray(a,compositeData.ProjectID);
doc.replaceItemValue("ValidProjects",a );
for (var v in a)
dBar.info("After removed V=" + v);
doc.save();
function removeFromArray(arr, val) {
for(var i=0; i<arr.length; i++) {
dBar.info("Value = " + arr[i] + " Remove = " + val);
if(arr[i] == val) {
dBar.info("Removing " + i)
arr.splice(i, 1);
break;
}
}
}
The removeFromArray is being called successfully and I can see the “Removing 0” message displayed in the debugbar as expected but the array does not change at all and the value is not removed. Any ideas?
Treat the ItemValues as Vector.
Hope that helps