AnsweredAssumed Answered

JavaScript API Error on rule/action

Question asked by marcello.modica@logconsulting.it on May 10, 2013
Latest reply on May 17, 2013 by marcello.modica@logconsulting.it
I'm try to write a script for create a new subfolder when email is send to an alfresco folder (associted to an alias) via SMTP.
I need to create this subfolder under the folder that is performing the rule;therefore, the new folder should be named as the Subject field of the email arrived.
The script is associated to the folder via rule, and i try to execute it in backgroud and not. The rule i applied only to document that have the "emailed" Aspect.

I cannot use the debugger, because an issue of alfresco 4.2d edition. But i had try debugging code omitting some line and the error is in the -document.properties["cm:subjectline"] - function. If i set it with static string the folder is created.

This is the code/flow:

/* The mail new mail arrive to folder with alias rnc@cms.pasello.com */

var id = companyhome.id;
var name = companyhome.name;
var type = companyhome.type;
var noderef = companyhome.nodeRef;
var childList = companyhome.children;
var properties = companyhome.properties;
var assocs = companyhome.assocs;


/*I change doccument mimetype for correct  preview and save it */
document.mimetype="text/html";
document.save();

/*Add a new folder naming it with the same name as email subject */
var newRNCFolder = space.childByNamePath(document.properties["cm:subjectline"]);
if (newRNCFolder == null && space.hasPermission("CreateChildren"))
{
   // create the folder for the first time
   newRNCFolder = space.createFolder(document.properties["cm:subjectline"]);
}

space.save();

Outcomes