In Alfresco Share, Form service is widely used for property editing, searching, document creating, workflow task editing, etc. A Share form is a set of form fields. The form control is introduced to provide the proper way to input the value for a form field, such as controls for date and time, association, mime-type, etc. The default form control for a field with associations to a group and/or person is authority.ftl. It helps to input a user or group by searching within a whole repository. In many scenarios, navigation and searching within certain groups are needed.
To build this custom form control for members of a group, the existing webscript is needed to provide information for a group and the children need to be fixed. A member of NodeRef would be added into the output JSON. Two files need to be overridden for this purpose:
The rest tasks would be creating the prototype Alfresco.GroupMember in group-member.js and use it in group-member.inc.ftl and group-member.ftl. A good idea is to build Alfresco.GroupMember to leverage the type Alfresco.ObjectFinder in object-finder.js.
Once the customization is deployed, the form control could be used in any form setting like the following:
<config evaluator= »task-type » condition= »ihm:assignReviewerTask »>
<show id= »ihm:assignee »/>
<field id= »ihm:assignee » label-id= »assoc.ihm_assignee »>
<control template= »/org/alfresco/components/form/controls/group-member.ftl »>
<control-param name= »startLocation »>IHM_REVIEWER</control-param>
<control-param name= »authorityType »>USER</control-param>
<control-param name= »deepSearch »>true</control-param>
There are three parameters for this control:
startLocation: the root group for picking the members
authorityType: the type of the field, with three options GROUP, USER, ALL
deepSearch: indicator for searching, true to search for all children and false to search for direct children.
If these parameters are ignored, the default ones would be supplied as group root, ALL and false.
This control is a good solution for workflow task editing when one or more members of certain group are needed.