Set Form Values Plugin
Set values in topic form fields based on changes of other form fields
This plugin enables automatic setting of values in form fields when you save a topic - based on the the change of another form field.
The typical application is to set the date of a field when another field changes to a specific value.
For example - you may have an application with a form field "State" that can have the values "New", "Assigned", and "Completed". And you have 3 date fields "Date Created", "Date Assigned", and "Date Completed".
You know your users will often forget set these dates manually.
This plugin will set the dates for the 3 date fields when the State field changes
from any other value, to the value specified by a rule. You can save the same topic multiple times, without changing the State field. The date field will only update when the State field changes to the rule value.
Rules are defined in a rule topic by a simple table. The rules topic is defined by a preference setting SETFORMVALUESPLUGIN_RULES which can be set per site, web or topic.
The format of the table can be seen in the example in the next section.
Note that when working with field names, spaces must be removed (like you must also do with for example SEARCH)
The rules for setting fields are defined by a rules topic.
To enable the rules define a preference setting SETFORMVALUESPLUGIN_RULES which point to the rules topic
An example of a rules topic is
* Set NOAUTOLINK = on
| *Form* | *Match field* | *Match value* | *Target Field* | *Target Value* | *Condition* |
| SubmissionRecordForm | State | New | DateCreated | $date | |
| SubmissionRecordForm | State | Assigned | DateAssigned | $date | |
| SubmissionRecordForm | State | Performed | DatePerformed | $date | |
| SubmissionRecordForm | State | Completed | DateCompleted | $date | |
| SubmissionRecordForm | State | Completed | DatePerformed | $date | EMPTY |
The columns are
- Form which must be defined on the topic
- The name of the field that must change to trigger the plugin
- The value to which this field must change. Simple regex are allowed incl .* (match any change)
- The name of the target field
- The value of the target field. You can use $date and $time to define date and time for the field. Date follows the format for the Foswiki site
- Optional condition. Only valid value is to leave blank or the exact string EMPTY. The EMPTY condition means that the value is only set if the field is empty. This prevents overwriting an existing value. In the example above it is used to set the field "DatePerformed" when the State changes to Completed if the State has never been set to Performed.
- The NOAUTOLINK is only to prevent the table from showing field names as broken wiki links in case no topic is defined for the field name
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. Use "Find More Extensions" to get a list of available extensions. Select "Install".
If you have any problems, or if the extension isn't available in
, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions
for more help.