As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
can anyone help me in this..
Hi,
You can use lucene search for searching all the content of type cm:folder for that particular site and then just get the length of the result.
var result = lucene.search("-----Your Query----");
var a = result.length;
Thanks,
Yash
You can use the following javascript code and execute it in a recursive way.
var site = companyhome.childByNamePath("Sites/<site-name>/documentLibrary");var count = site.children.length;
The above code will give you the number of children present in documentLibrary.
You can use the same to get the subfolders.
Regards,
Kintu
ContCentric
I don't know javascript, can you pls give me the code with recursive logic and also give me the URL pattern for this
Hi Yash..!!
I have no idea about lucene search can tell me the alternate way for getting folders and sub folders
Use the following code:
var site = companyhome.childByNamePath("Sites/test/documentLibrary");var children = site.children;var numberOfChildren = site.children.length;var count = 0;for (var index = 0; index < numberOfChildren; index++) { if(children[index].isContainer){ c = children[index].children.length; count = count + c + 1; } else { //uncomment following line if you want to count the document as well //count = count +1; }}logger.log(count);
var site = companyhome.childByNamePath("Sites/test/documentLibrary");var children = site.children;var numberOfChildren = site.children.length;var count = 0;
for (var index = 0; index < numberOfChildren; index++) { if(children[index].isContainer){ c = children[index].children.length; count = count + c + 1; } else { //uncomment following line if you want to count the document as well //count = count +1; }}logger.log(count);
I hope you know where to use it.
Note: replace the 'test' with your site name.
It is giving wrong count
Can you once check?
Please, never recommend using the luceneSearch operation. That operation is a legacy holdover from Alfresco 2.x/3.x. Lucene is no longer the primary search language, and since Alfresco 4.x has not received any of the various performance improvements that have been accorded to FTS / CMIS. Ideally, only ever use the generic query() operation and specifically use the "fts-alfresco" or "cmis-strict"/"cmis-alfresco" query languages.
Thanks for the clarification!