In standard Alfresco forms, a field is displayed as a picklist only if the field is associated to a constraint that enumerates the allowed values. Constraints are great but changing them has two problems: first no user interface is provided and a developer’s intervention is required to edit the content model xml, second Alfresco has to be stopped and restarted after every change.
This is where a picklist plugin comes to rescue. A picklist plugin allows administrators to define lists of values to be used in picklists. The lists can be changed dynamically without restarting Alfresco.
Requirements and implementations may vary, but the following five plugins are excellent examples of what can be done.
Alfresco Listmanager by Erik Billerby provides an admin interface where picklists and their values can be edited online, easily without restarts. The interface is integrated in Share’s admin tools.
Multiple lists can be defined and each list can have its values. The following screenshots shows a ‘comment’ field bound to the ‘comments’ picklist managed by listmanager.
This plugin is handy if you want your lists managed centrally by an administrator for all Share sites.
Alfresco Value Assistant
Data lists can be enabled for any Share site. The plugin adds a new data list type called ‘Value Assistance List’. Here I show how to use it to create a list of faculties:
… and to define the allowed values:
Now the list can be attached to a field:
Alfresco Datalist Constraints
Alfresco Datalist Constraints by Angel Borroy is another plugin that takes advantage of Share’s data lists to define picklists and picklist values.
Unlike the previous plugin, Alfresco Datalist Constraints requires a special Share site called “administration” (the name can be customised) that will manage the data lists. Here is how a data list of type “Options” is created:
… and populated:
Then the picklists can be used in any site just like for the previous plugin.
Alfresco Colleagues Picker Form Control
Alfresco Colleagues Picker Form Control by Douglas C. R. Paes shows how picklist values can be taken from other nodes in the repository: in this case users or groups of the system, i.e. cm:person or cm:group nodes.
To be correct, the plugin uses a “value picker” rather than a “picklist”. The UI is different but the concept is the same.
The plugin also demonstrated that arbitrary filtering can be applied to provide the list of values. In this case only users that are colleagues of the currently logged in user.
Here is how a form looks like:
And here is the picker to choose a user:
Share Form Control Dependency
Share Form Control Dependency by Rui Fernandes takes a different tack: its goal is to manage dependencies between different picklists, where the choice for one picklist determines the available options for another picklist. This problem is also known as “cascading values” or “synchronised picklists” as the choice on one picklist automatically triggers a reload (via ajax) of the options on another picklist.
Here is what a form looks like:
Notice that field “Sub Area” depends on field “Area”. Options “Sub Area B1” and “Sub Area B2” are shown because option “Area B” was selected for field “Area”.
You might wonder where the options and their dependencies are declared. The plugin declares options using regular content model constraints. On the other hand, dependencies are declared through a naming convention that involves numbers as the prefix of each option – you never see the numbers in the UI but they are processed behind the scenes by the plugin. For more details, see the Rui Fernandes’ explanation.
Dynamic picklists are a common requirement in Alfresco projects. The five plugins show how the problem can be approached and the variety of solutions that can be found. All the plugins are open source so if you have time to dig into the details, a lot can be learnt. But more on this in a later post…
As further reading, I recommend an “External Master Data in Alfresco: Integrating and Keeping Metadata Consistent Across Multiple Systems” presented at the 2014 Alfresco summit in London by Alexey Vasyukov and Oksana Kurysheva. This excellent presentation digs into the issues related to maintaining Alfresco picklists synchronised with external data sources, and shows real-life examples, trade-offs and solutions.
The presentation also points to the Alvex Master Data Component, now part of Alvex, but soon to be extracted as a separate component. Looking forward to review it here when it’s released.