using free and open source software in the geology space

Use Alfresco folder rules to perform admin tasks

Introduction

Folder rules are ordinarily used to initiate tasks when files are created or updated, but they can also be a convenient way to manage admin or migration tasks. For example, you might need to perform bulk changes to properties of files.

Note that if you want to process files in subfolders, you will need to choose ‘Run rules for this folder and its subfolders’ – even though you have ticked ‘Rule applies to subfolders’ above.

Run rules for the folder and sub-folders

Note that when you click ‘Run Rules’, ALL the enabled rules for the folder are run, so you need to disable all rules that you don’t want to run. In the example below, only the ‘Create thumbnails’ rule will run, as the other rules have been disabled.

Rules for the Fieldobs folder – rules 1, 2, 3 and 5 are disabled

Scripts – extending the power of folder rules

There are many types of tasks that you can choose when defining a folder rule, but you can extend these choices even further by creating scripts in the ‘Scripts’ folder under the ‘Data Dictionary’ folder. All of the scripts in this folder that have the extension ‘.js’ are listed when you choose ‘Execute script’ in your folder rule.

All scripts stored in the ‘Scripts’ folder can be run within folder rules

The are many useful sample scripts in this folder. ‘example test script.js.sample’ is a good script to start with – it shows ways of accessing the properties of each file/subfolder – for example …

Note that the javascript in the folder rules runs on the Alfresco server and the API that is used to access properties of documents, photos, etc. is sometimes referred to as the ‘Alfresco Repository JavaScript API’. Do not confuse this with the ‘Alfresco Share JavaScript API’ which runs on the client – ie. in the user’s browser. The following section in the official docs explains the various programming interfaces to Alfresco – http://docs.alfresco.com/community/concepts/API-intro.html

Order of the Bee – an independent organisation of the Alfresco community. Web-site includes good technical and non-technical posts and other information, focussed mainly on Alfresco Community Edition (CE).