Find only sub-folders, not type content in javascript search

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Customer

Find only sub-folders, not type content in javascript search

Jump to solution

Hi,

I have following code

nodes = search.query({
	language: 'fts-alfresco',
	query: 'ANCESTOR:"workspace://SpacesStore/a0617f12-8eba-4dce-a5b5-59afec623010"+nodeType:"cm:folder"',
	maxItems: 2000
});

But this gives me also all documents in all sub-folders. I only want objects of type folder.

All help appreciated.

1 Solution

Accepted Solutions
Highlighted
Established Member II

Re: Find only sub-folders, not type content in javascript search

Jump to solution

Have tou tried a query like:

'ANCESTOR:"workspace://SpacesStore/a0617f12-8eba-4dce-a5b5-59afec623010" AND TYPE:"cm:folder"'

View solution in original post

12 Replies
Highlighted
Established Member II

Re: Find only sub-folders, not type content in javascript search

Jump to solution

Have tou tried a query like:

'ANCESTOR:"workspace://SpacesStore/a0617f12-8eba-4dce-a5b5-59afec623010" AND TYPE:"cm:folder"'

View solution in original post

Highlighted
Customer

Re: Find only sub-folders, not type content in javascript search

Jump to solution

Simple as that Smiley Happy

Thanks!

Highlighted
Customer

Re: Find only sub-folders, not type content in javascript search

Jump to solution

Hi,

One more question. Why does following code

function main() {
	log = "*** Start script ***\n";
	logFile.content += log;
	
	nodes = search.query({
		language: 'fts-alfresco',
		query: 'ANCESTOR:"workspace://SpacesStore/a0617f12-8eba-4dce-a5b5-59afec623010" AND TYPE:"cm:folder"',
		maxItems: 2000
	});

	log = "   -> Gevonden mappen: " + nodes.length + "\n";
	logFile.content += log;

	log = "*** Einde script ***\n";
	logFile.content += log;
}

var logFile = space.childByNamePath("log.txt");
var nodes = null;
if (logFile == null)
{
   logFile = space.createFile("log.txt");
}
var log = "";
main();

give me an output that repeats the logging a hundred times? I get in the log output file hundred times the 'Start script', 'Gevonden mappen' and 'Einde script'.

Highlighted
Established Member II

Re: Find only sub-folders, not type content in javascript search

Jump to solution

Mmmm maybe you are appending the logs to the file at every script execution, instead of creating new content for the file? If that is not the cause, I don't know what could it be... 

Highlighted
Customer

Re: Find only sub-folders, not type content in javascript search

Jump to solution

I delete the log file before executing the script, so...

 

The script is executed via a rule on a folder, and it looks like it is executed for each sub-folder in that folder.

Highlighted
Established Member II

Re: Find only sub-folders, not type content in javascript search

Jump to solution

Then check that subfolders have the "inherit rules" option deactivated.

Also, depending on how you want to trigger this rule, take a look at the "apply rule to subfolders" option in rule configuration, to see whether it is well configured. 

Highlighted
Customer

Re: Find only sub-folders, not type content in javascript search

Jump to solution

I deactvated the inherit rules on some of the sub-folders, but the number stays the same. 

The option to apply the rule to subfolders is not activated.

Highlighted
Established Member II

Re: Find only sub-folders, not type content in javascript search

Jump to solution

Then I don't know what could it be. It seems the rule is triggering for a lot of nodes. What is your rule configuration, triggers, etc?

Highlighted
Customer

Re: Find only sub-folders, not type content in javascript search

Jump to solution

Rule definition.png

Nothing special I think. What I think is strange is that it looks like the script executed for each sub-folder.