Sep 1, 2011 4:26 PM
66 Posts

Re: Update multiple documents in view by key(s)

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 6
Thanks for the reply Sven...I think I'm close...I changed the following in the code below and if I have just key it works. If I try to add more than one key/element (commented out below) the backend document doesn't get updated/saved on either. Any ideas?
 
var db:NotesDatabase = sessionAsSigner.getDatabase("","Database.NSF");
var view:NotesView = db.getView("ViewName");

var keyV = new java.util.Vector();
keyV.addElement("1234");
//keyV.addElement("4321");
var LookupDoc:NotesDocument = view.getAllDocumentsByKey(keyV);
 
LookupDoc.stampAll("BackendField", newValue);
Sep 1, 2011 4:44 PM
291 Posts
you got some code issues here
see this color, I am also assuming your LookupDoc is not getting set, put in a if statement or debug print statements to test this. I am not sure using a vector of more than one object will work like you think. A vector is used to search in multiple sorted columns. IE, the first element searches the first sorted column and then the second element searches the next sorted column for that row. It will not get a collection of all documents that match the Vector's elements in the first sorted column. From Help: Finds documents based on their column values within a view. You create a key or vector of keys, where each key corresponds to a value in a sorted column in the view. The method returns all documents whose column values match the keys. Defined in View Syntax public DocumentCollection getAllDocumentsByKey(java.util.Vector keys) throws NotesException public DocumentCollection getAllDocumentsByKey(Object key) throws NotesException public DocumentCollection getAllDocumentsByKey(java.util.Vector keys, boolean exact) throws NotesException public DocumentCollection getAllDocumentsByKey(Object key, boolean exact) throws NotesException Parameters java.util.Vector keys String, Number, DateTime, or DateRange objects that are compared to sorted columns in the view. The first element in the vector is compared to the first sorted column in the view; the second element is compared to the second sorted column; and so on. Also, see my comments in your code below. var db:NotesDatabase = sessionAsSigner.getDatabase("","Database.NSF"); var view:NotesView = db.getView("ViewName"); var keyV = new java.util.Vector(); keyV.addElement("1234"); //keyV.addElement("4321"); //the next line returns a NotesDocumentCollection object not a document var LookupDoc:NotesDocument = view.getAllDocumentsByKey(keyV);  //stamp all only works on collections not a NotesDocument class LookupDoc.stampAll("BackendField", newValue); Howard