06-19-2017 09:10 AM
Hi all,
I use following javascript (only snippet of the code):
function main() {
if (document.isContainer && document.name == "Gescande dossiers")
{
processNode(document);
}
}
main();
I have a rule defined on the document library that executes that script, when folder "Gescande dossiers" is found it should continue. But it seems this is only iterating documents in the current folder, not the subfolders.
Function main() does not iterate on all object in the folder?
Thanks,
Patrick
06-19-2017 10:41 AM
Why should main() iterate over all objects in the folder? There is no line of code that implies a recursion or loop.
06-20-2017 02:52 AM
Because that's the implemenattion of main(), as far as I know. I used it that way several times.
06-20-2017 03:05 AM
sorry, but no - "main" ist just a name, could also be "patrick". No logic is implied if you use main.
Your code could also be
if (document.isContainer && document.name == "Gescande dossiers")
{
processNode(document);
}
}
and would do the same. Your rule, as far as the code says, does the following:
- document is the node that has triggered the rule
- check if triggering node is a container (folder) and has the name "Gescande dossiers"
- if yes, call processNode with the node "Gescande dossiers"
processNode would have to do the job to iterate over the children of "Gescande dossiers" (=document).
Maybe you want something different - if your rule applied to subfolders too? Then maybe you don't want to check if "document.name" is "Gescande dossiers" but document.parent.name ... ?
06-20-2017 03:33 AM
Sorry, but I do not agree, cause when I put logging on for 'document.name' it gives me a record for each file, but not for the folders...
06-20-2017 04:02 AM
...if you are agree or not. It isn't working like you expect. To analyze what is going wrong, you would have to provide your rule definition and what you want to achieve.
If you define an incoming rule (onCreate) without any filtering, then it will be triggered by any object - file, folder or what else - that is created or moved to the corresponding folder (in which the rule is anchored).
06-20-2017 04:25 AM
Martin,
Sorry, you are right. It was the rule that was not defined correctly... I checked it and there was indeed a condition that was not defined correctly. It works now after correction.
Thanks.
Patrick
Explore our Alfresco products with the links below. Use labels to filter content by product module.