Samuel Omopariola
Samuel Omopariola

Reputation: 153

NotesException: Unknown or unsupported object type in Vector

I'm trying to add new names to the address book programmatically but I'm getting the following error:

[TypeError] Exception occurred calling method NotesDocument.replaceItemValue(string, Array) Unknown or unsupported object type in Vector

Code snippet below:

var addressBook = session.getDatabase("","names.nsf");
var gView:NotesView = addressBook.getView("($VIMGroups)");
var gDoc:NotesDocument = gView.getDocumentByKey("groupName", true);

var newg:java.util.Vector = [];
var mems:java.util.Vector = new Array(gDoc.getItemValue('Members'));
newg.push(mems);

var newNames:java.util.Vector = new Array(getComponent("NewMems").getValue());
newg.push(newNames);

gDoc.replaceItemValue("Members", newg);
gDoc.save();

Adding a single user works fine, but then it does not save users in the required canonical format below:

CN=John Doe/O=Org

Instead it is saved in the original format below:

John Doe/Org

I look forward to your suggestions. Thanks.

Upvotes: 0

Views: 1306

Answers (3)

Samuel Omopariola
Samuel Omopariola

Reputation: 153

I was able to solve the issue using a forloop to loop through the list and push it into a newly created array. Using the forloop seems to make the difference.

var newg = [];
var group = new Array(getComponent("NewMems").getValue()), lenGA = group.length;
for(i = 0; i < lenGA; i++){
   newg.push(group[i]);
}
gDoc.replaceItemValue("Members", newg);
gDoc.save();

An explanation about this behaviour will be appreciated.

Upvotes: 0

Howard
Howard

Reputation: 1503

Don't use an Array (which is a JS thing). Initialize it as a Vector.

var newg:java.util.Vector = new java.util.Vectory();

Then look up the Vector methods to see how to add to that vector. Not sure if you will have to convert the names using the Name method but I would store them as "CN=Joe Smith/O=Test Org" to be sure you got the right format.

Upvotes: 0

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

You can't store an Array in a field. Make newg a java.util.Vector instead and integrate with that.

For OpenNTF Domino API the team wrote a lot of code to auto-convert to Vectors, which may cover Arrays.

Upvotes: 2

Related Questions