AnsweredAssumed Answered

Alfresco lucene query using Javascript

Question asked by informatica4plus on Aug 25, 2017
Latest reply on Aug 26, 2017 by afaust

Hello,

 

I'm trying to create a job in Alfresco that search documents created between a range of dates and send it automatically.

 

From schedule-action-services-context.xml, I'm calling this Javascript file that tries to do a lucene query and send results using mail but it doesn't work. In Alfresco log, does not appear any error and no email is send.

 

var nombredoc = document.properties["{http://www.alfresco.org/model/content/1.0}name"];

var finicio = "2017\-08\-01T00:00:00";
var ffin = "2017\-08\-31T00:00:00";
var query = "@cm\\:created:[" + finicio + " TO " + ffin +"]";

var documentos = search.luceneSearch(query);
var log = "";
for (var i=0; i<documentos.length; i++)
{
   log += "Nombre: " + documentos[i].name + "\tRuta: " + documentos[i].displayPath + "\r\n";
}

var mail = actions.create("mail");
mail.parameters.html = "html";
mail.parameters.from = "informatica@mydomain.com";
mail.parameters.to = "informatica@mydomain.com";
mail.parameters.subject = "Documento: " + nombredoc + " - " + log;
mail.execute(document);

 

I've tried with simple query like "TEXT:contracts"and works fine, but with date ranges I've got a lot of problems.

 

Regards

Outcomes