cancel
Showing results for 
Search instead for 
Did you mean: 

create a dynamic space

alessioa_
Champ in-the-making
Champ in-the-making
Hi to all the folks,
a question about template space…
Is it possible to have a template space where the name is created automatically?
For example if i want that when i add a file in a folder a sub-space based on a my custom space is creating with the name (or part of it) of the file name, is it possible?
Thanks
Best regards
Alessio
2 REPLIES 2

gavinc
Champ in-the-making
Champ in-the-making
It should be possible by using a rule in the space.

You can setup a rule to run some Javascript when new content is added to the space, that script could retrieve the name of the space and set the name of the content being added appropriately.

alessioa_
Champ in-the-making
Champ in-the-making
Hi gavinc, thanks for your answer…
I follow your hint, created a rule that execute my javascript file.
For creating a sub-folder with the same name of the file added in the space i used this code:
var docname =
document.name.substring(0, document.name.lastIndexOf('.'));

var folderNode = space.createFolder(docname+"_created by script");

But received this error:

Transaction didn't commit: Failed to execute script 'workspace://SpacesStore/d6c0d062-6b44-11db-ab0d-17c8a2cd352f': Wrapped java.lang.StringIndexOutOfBoundsException: String index out of range: -1 (AlfrescoScript#16)

Could be useful to know that the same error occours in the embedded  Alfresco example in Data Dictionary > Scripts > example test script.js

Thanks for the attention,
Best regards
Alessio A.