AnsweredAssumed Answered

Howto Remove Entries from a Map in Rhino JavaScript

Question asked by stevewickii on Aug 27, 2008
Latest reply on Dec 1, 2008 by mruflin
I am trying to remove a property from a node using the JavaScript API.  It should be possible.  I use the search.luceneSearch("query…") to get a list of ScriptNode objects.  Each ScriptNode has a "properties" member of type ScriptableQNameMap, and ScriptableQNameMap has a delete(String name) and remove(String name) method which both are defined to remove a property from the Map.

My problem is that I keep getting this error when I execute 'Delete Property.js': "EvaluatorException: missing name after . operator"

URL:  http:// localhost:9080/alfresco/command/script/execute?scriptPath=/Company%20Home/Data%20Dictionary/Scripts/Delete%20Property.js&property=fs:searchMeta

Delete Property.js
function main()
{
  if(!args.property)
  {
    return "Missing required request parameter: property";
  }

  var nodes = search.luceneSearch("TYPE:\"{www.fmcStars.nk.com/model/webcontent/1.0}downloadable\"");
  var propertyName = args.property;

  var str = "Deleted Property '"+ propertyName+" from the following Nodes:<hr>\r\n";

  for each (var node in nodes)
  {
    node.properties.delete(propertyName);
    node.save(); // This method uses NodeService.setProperties(), which should remove any properties from the Node that are not in the node.properties map.
    str += node.name+"<br>\r\n";
  }
  return str;
}

main();

Any help would be much appreciated.

Thanks!

Stephen

Outcomes