cancel
Showing results for 
Search instead for 
Did you mean: 

Create automatically folders

david82
Champ in-the-making
Champ in-the-making
There any way to create automatically subfolders in the user's folder when I create this user??? Rules, scripts, etc…

Thanks!
1 REPLY 1

david82
Champ in-the-making
Champ in-the-making
I've progressed a bit, I created a rule that runs when the folder is created, this rule calls the next script:

resultString = "create_space.failed";var parentNodeId = 'User Homes/',spaceName = 'facturas',spaceTitle = "Carpeta de pruebas" ,spaceDescription = "Descripcion de la carpeta de pruebas" templateId = '';var nodeNew;if ((spaceName == null) || (spaceName == "")){   resultString = "create_space.missing_name";}else{   var nodeParent = search.findNode("workspace://SpacesStore/" + parentNodeId);   // Copy from template?   if ((templateId != null) && (templateId != ""))   {      nodeTemplate = search.findNode("workspace://SpacesStore/" + templateId);      nodeNew = nodeTemplate.copy(nodeParent, true);      nodeNew.name = spaceName;   }   else   {      nodeNew = nodeParent.createFolder(spaceName);   }      // Always add title & description, default icon   nodeNew.properties["cm:title"] = spaceTitle;   nodeNew.properties["cm:description"] = spaceDescription;   nodeNew.properties["app:icon"] = "space-icon-default";   nodeNew.save();   // Add uifacets aspect for the web client   nodeNew.addAspect("app:uifacets");   if (nodeNew != null)   {      resultString = "space_created";      resultCode = true;   }}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I take this code from the file docActions.get.js.  But when I run I get an error, and looking at the firebug gives me the next answer:

 "exception" : "org.alfresco.scripts.ScriptException - 04100119 Failed to execute script 'workspace:\/\/SpacesStore\/6b697df7-38b1-4a87-804d-5426c80d8b1c': 04100118 TypeError: Cannot call method \"createFolder\" of null (workspace:\/\/SpacesStore\/6b697df7-38b1-4a87-804d-5426c80d8b1c#29)",‍

Any idea?