JavaScript to create a child node
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 01:25 PM
Hi all
Have a quick question please. I need to create a JS script for Alfresco that would look for a space and if found, will create in it a child space with a given name.
I know to look for the parent Space I can use this code
So then to create the child node I have created this
but with this what I get is the "child space" to be created at the same level than the Parent Space, not inside the Parent Space
Any Suggestions on how I can "tell" the code to create the child space inside the Parent Space?
Thanks a lot guys
Have a quick question please. I need to create a JS script for Alfresco that would look for a space and if found, will create in it a child space with a given name.
I know to look for the parent Space I can use this code
var ParentSpace = space.childByNamePath("parentSpaceName");
So then to create the child node I have created this
if (ParentSpace != null && space.hasPermission("CreateChildren")){ ChildSpace = space.createFolder("ChildName");}
but with this what I get is the "child space" to be created at the same level than the Parent Space, not inside the Parent Space
Any Suggestions on how I can "tell" the code to create the child space inside the Parent Space?
Thanks a lot guys

Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2009 04:03 PM
The "space" variable will always be populated with the space the script is currently running against. Similar with "document" although you aren't using that in this example.
So instead of space.createFolder() you need to do ParentSpace.createFolder(). Also, in your hasPermission() check, you want to run that on the ParentFolder, not the current space.
Jeff
So instead of space.createFolder() you need to do ParentSpace.createFolder(). Also, in your hasPermission() check, you want to run that on the ParentFolder, not the current space.
Jeff
