Generate drop down list of members of a group for select formfields


You have a web that is only editable by members of a certain group (to keep things simple lets call these team webs). You have a number of forms used in each team web and in these forms you use select form fields.

How do you approach getting this list automatically populated in each web without having to manually define it in each web?

The following is an approach that I took to solving this issue.. It may not be the most elegant but it works.. Do feel free to modify any of the below if you think you have a better approach..


You have two teams TeamA and TeamB each of which have a seperate team web which they use for their daily work. These webs are called TeamWebA and TeamWebB There are a number of wiki applications in use in each web (some use CommentPlugin custom templates) and you want to be able to populate drop down lists based on the members of the group which are TeamAGroup and TeamBGroup (You don't need to use these group names they are just used for clarity)


Add a simple form to the front page of each of the team webs with the formfield Team_Group which the members belong to.. To centralize things create the form in the Main web (or another dedicated web) called TeamDetailsForm. An example of this form could be:

| *Name:*| *Type:* | *Size:* | *Values:* | *Tooltip message:* | *Attributes* |
| Team_Name | text | 120 | | Corporate Name of Team| H |
| Team_Overview | text | 120 | performs .... | Brief description of the team function | H |
| Team_Group | select | 1 | %LIST_OF_GROUPS% | Team Group | H |

Where LIST_OF_GROUPS is a search which can be placed in Main.SitePreferences which looks like:

      * Set LIST_OF_GROUPS = %SEARCH{"GROUP" web="Main" topic="*Group" type="regex" excludetopic="AdminGroup" nonoise="on" multiple="off" format="<option>$topic</option>"}%

Once the team defines the group using this form you can start to populate the lists.

Put the following in the preferences topic Main.SitePreferences

      * Set TEAM_GROUP = %FORMFIELD{"Team_Group" topic="%INCLUDINGWEB%.WebHome"}%
      * Set TEAM_MEMBERS = %SEARCH{"GROUP" web="Main" topic="%TEAM_GROUP%" order="$pattern" type="regex" casesensitive="on" nonoise="on" format="$pattern(.*Set GROUP =([^\n]*).*)"}%
      * Set TEAM_MEMBERS_SELECT = %FORMATLIST{"%TEAM_MEMBERS%" format="<option value=\"$1\">$1</option>" separator=""}%

You can then use the above variables throughout the team webs. (And takes away many headaches smile )

Why did I use FilterPlugin you may ask? The simple reason being that it allows us to use the variable TEAM_MEMBERS_SELECT in custom CommentPlugin templates. I did try to use the following:

      * Set TEAM_GROUP_SELECT=%SEARCH{"GROUP" web="Main" topic="%TEAM_GROUP%" casesensitive="on" nonoise="on" format="$percntCALC{$LISTJOIN($sp, $LISTMAP(<option value=\"$web.$item\">$PROPERSPACE($item)</option>, $TRIM($pattern(.*Set GROUP =([^\n]*).*))))}$percnt" }%

But this does not work with CommentPlugin as it does not handle the CALC functions..

You can use the following code for selects in a custom CommentPlugin template

<select name="name"id="eventUser" name="eventUser" >

Known Uses

The above can have a number of uses

and many more...

Known Limitations

  • This only works for the default topic-based UserMapper.
  • The initial formatted search does not handle nested groups.

See Also

BestPracticeTipsForm edit

Category Developing Wiki Applications
Topic revision: r2 - 02 Feb 2010, OliverKrueger - This page was cached on 10 Jan 2018 - 13:35.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License