cancel
Showing results for 
Search instead for 
Did you mean: 

Deep Folder Structure

dsr_471
Champ in-the-making
Champ in-the-making
Hi All,

I've a requirement to get deep folder structure of a particular folder using JavaScript in Alfresco
The structure is
Ex:-
 
Main Folder
   |—- Document 1
   |—- Folder 1
              |—– Document 2
              |—– Folder 2
                          |—– Document 3
                          |—– Folder 3
                                      |—– Soon……………………..

I written the following code ,

var nodeRef = "workspace://SpacesStore/36a2704b-1fbe-4223-9dc6-169a3ff31384";
var docNode = search.findNode(nodeRef);
var childList = docNode.children;
var count = childList.length;
   for(var i = 0; i < count; i++)
    {
      var child = childList[i].name;
        logger.log( docNode.name+": children is: " + child);
      }
    

but the output is getting only

folder1: children is: Document1
folder1: children is: Folder1
I'm unable to get remaining structure…
Please suggest how to get total structure

Help is very appreciated.

thanks
3 REPLIES 3

ddraper
World-Class Innovator
World-Class Innovator
The problem is that you're only iterating over the children in the main folder. You need to modify your code so that you not only iterate over the children of the main folder, but also of the children of each child node (and so on, until you reach a node that has no children). One approach would be to use a recursive programming pattern.

Regards,
Dave

dsr_471
Champ in-the-making
Champ in-the-making
hi Dave,

Thanks for giving reply. can u please tell me how to get that structure trough programming pattern..

Regards,
DSR

ddraper
World-Class Innovator
World-Class Innovator
I don't think that this is the correct forum to be answering general programming questions. If you have any Alfresco specific questions then you should post them here, but you're essentially asking if I can show you how to write a basic recursive program loop. I think you'll find that there are plenty of resources on the internet to help you get to grips with this - I'd recommend trying a Google search,

Regards,
Dave
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.