I developed a script which triggered when items created or deleted. Its function is only to check whether a folder (container) is having a document (isDocument) or not. I use the traverse/recursive method to check.
After do some iterate checks and read my logs, I found that the behavior on how the sequence of "file/document activities" and "script is executed".
- When items is created, the activities of file created or moved into a directory is running first then the script will run afterwards;
- When items is deleted, the script will run first (and will capture whole the structures), then file activities will run (deleted or move into another places)
With above situations, I have a trouble when there's 1 (one) file inside a folder, I delete it, next the script will run and reported that it's still found one file inside that folder. Instead of no file found in that folder.
If items are created is working fine as expected.
What is the right method or approach of my problem above?
My script is attached.