Lucine search & how to get noderef’s

Snippet piece of code. Lucene search for something & then get the noderefs.

var docs = search.luceneSearch(” @cm\\:name:\””+args.filename+”\””);
var log = “”;
for (var i=0; i<docs.length; i++) {
log += “NodeRef: ” + docs[i].nodeRef + “\r\n”;
logFile.content = log;


Alfresco debugger

The Alfresco debugger is a big help for me :


Just open the page – click enable – and see your server side code step by step popping up.

Wont work for webscripts, but helped me a lot while making custom actions.

Making a Dashlet work in Alfresco Share

Go to this folder : (this is where my tomcat/alfresco3.4.4 is installed)


Add three files :


   <description>MJB's test Dashlet</description>


<div class="dashlet">
   <div class="title">${title}</div>
   <div class="body">
	<div> cmisQuery       = ${cmisQuery!""} </div>
	<div> Aantal entries  = ${no_entries!""} </div>
   	<div> props[icon]     = ${props["icon"]!""} </div>
      	<div> props[propName] = ${props["propName"]!""} </div>
	<div> doc             = ${doc!""} </div>
	<div> object          = ${object!""} </div>
	<div> properties      = ${properties!""} </div>
	<div> Qname           = ${Qname!""} </div>
	<div> propName        = ${text!""} </div>
	<div> name	      = ${name!""} </div>


// Needs to come from cmis:document because cmis:file returns nothing
var selectString =  "SELECT d.*, t.*, a.* FROM cmis:document AS d " +
		    "JOIN cm:titled AS t ON d.cmis:objectId = t.cmis:objectId " +
		    "JOIN cm:author AS a ON d.cmis:objectId = a.cmis:objectId " +
		    "WHERE IN_FOLDER(d, 'workspace://SpacesStore/560b8dd6-6503-4ad5-8066-5946c1456ec1') " +
		    "ORDER BY d.cmis:name"

var cmisQuery = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><cmis:query xmlns:cmis=\"\"><cmis:statement>" + selectString + "</cmis:statement></cmis:query>";

// get the documents for the currently active site
var conn = remote.connect("alfresco");

var result ="/cmis/queries"), cmisQuery, "application/cmisquery+xml");

	if (result != null) {model.title = "ik krijg iets terug van de query";} else { model.title = "ik krijg niets terug van de query"; }
	model.title = "resultset from query";	// Titel voor de dashlet
	model.result = result;					// keihard de XML -als ruw block data- overgooien.
	model.cmisQuery = cmisQuery;			// Query weergeven

// Lets make a proof of the pudding model.

function getElementByTagName(list, elTagName) {
   var el;
   for (var i = 0, l = list.size(); i < l; i++) {
      el = list.get(i);
      if (el.QName.localPart == elTagName) {
	 model.Qname = el;
         return el;
   return null;

function createModel(feed) {
  var list = new Array();
  var entries = feed.getEntries();
  model.entries = entries;
  model.no_entries = entries.size();

  for (var i=0; i < entries.size(); i++) {
    var doc = entries.get(i);
        model.doc = doc;
    var object =  doc.getExtension(atom.createQName("","object"));
    model.object = object;
	properties = getElementByTagName(object.getElements(), "properties"); = properties;
    propertiesList = properties.getElements();
	var props = new Array();
	props["icon"] = doc.getExtension(atom.createQName("","icon")).getText();

	model.text = "";
	var mjb = true;

    for (var j = 0; j < propertiesList.size(); j++) {
      property = propertiesList.get(j);
      if (property != null && property.firstChild != null) {
		 model.text += property.getAttributeValue("propertyDefinitionId");

		 if ((property.getAttributeValue("propertyDefinitionId") == "cmis:name") && (mjb = true)) {
			mjb = false;
			//found cmis:name = property.firstChild.text;
		 var propName = localPart(property.getAttributeValue("propertyDefinitionId"));
		 props[propName] = property.firstChild.text;
		 model.propName = propName;
	model.props = props;
	list[i] = props;
  return list;

function localPart(qName){
  return qName.substring(qName.lastIndexOf(":") + 1, qName.length());

Note that the workspace ID works for me – but will not work for you. You will need to replace this : workspace://SpacesStore/560b8dd6-6503-4ad5-8066-5946c1456ec1
with a noderef to a directory with a files in it.

Get your own noderef by going into Alfresco – find  a nice looking directory – go to “View Details” – find the Alfresco Node Reference link – right-click and “Copy link adress” which has a similar format (workspace://SpacesStore/some-numbers-and-letters-with-dashes) Paste this is the javascript file (mjb.get.js)

Once the files are in place, your need to update the Alfresco Share webscripts library:
Press the refresh button – you should see 1 more webscript available.
Then login to share
Click ‘dashboard wijzigen’ and drag your new dashlet (called MJB) into it.

Yes I know it is very dirty code. It’s even throwing horrible looking output.
But it’s just a small proof of the pudding that shows it’s working.

Using Lucene search to find all user nodes in Alfresco.

Login to alfresco. Goto Administration console / Nodebrowser.
Select Lucene in the dropdown box @ search

Enter this query :


Results in all directories in the user_homes. As far as I know this should be equal to the users in the system. Note that this does not include the alfresco admin user. This has Company Home as ‘user-home’

The above code skipped users guest and admin. I decided to use this query:


This also gives admin and guest accounts and seems more natural to use.