cancel
Showing results for 
Search instead for 
Did you mean: 

Error while iterating a cmis result set within a webscript

leonardo_celati
Champ in-the-making
Champ in-the-making
I am in trouble with a simple task, basically I would like to iterate a CMIS result set within a web script, but a function not found error occurs.
This is the code:

var query = "…….";
var cmisConnection = cmis.getConnection();
var cmisSession = cmisConnection.getSession();
var results = cmisSession.query(query, false);

for(var res in results.iterator()) {
   var nodeRef = res.getPropertyValueById('cmis:objectId');
   var node = search.findNode(nodeRef);
   // …. rest of code….
}


I have already made sure that the result set is valid and filled with objects. The result is:

Cannot find function getPropertyValueById


Besides the main problem, I don't know if this fragment for retrieving the node is correct:


var nodeRef = res.getPropertyValueById('cmis:objectId');
var node = search.findNode(nodeRef);


1 REPLY 1

leonardo_celati
Champ in-the-making
Champ in-the-making
The problem is in the for loop. I am so deep into Java now that I forgot that this:


for(var res in results.iterator())


just iterate trough the set of property keys rather than values.

Instead, this works just fine:


var iterator = results.iterator();
while(iterator.hasNext()) {
  var res = iterator.next();
  var name = res.getPropertyById('cmis:name');
  // which is in the form of:
  // Property [[id=cmis:name, display Name=Name, local name=name, query name=d.cmis:name, values=[blog.html]][extensions=null]
  var values = name['values'];
  var value = values.get(0);

  // …. then the rest of the code….
}