TIP SetFormValuesPlugin is not installed on Foswiki.org.

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)

Plugin Preferences

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

Installation

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 configure, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.

Plugin Info

Dependencies: None
Change History:  
1.1 (30 Jul 2015): Added the Condition attribute.
1.0 (30 Jul 2014): Initial version
Support: http://foswiki.org/Support/SetFormValuesPlugin

Extensions.PackageForm edit

Author KennethLavrsen
Version 1.1
Release 1.1
Copyright 2013-2015, KennethLavrsen, All Rights Reserved
License GPL (GNU General Public License)
Home http://foswiki.org/Extensions/SetFormValuesPlugin
Support http://foswiki.org/Support/SetFormValuesPlugin
Repository https://github.com/foswiki/SetFormValuesPlugin
ExtensionType PluginPackage
DemoUrl http://
SupportUrl Support.SetFormValuesPlugin
I Attachment Action Size Date Who Comment
SetFormValuesPlugin.md5md5 SetFormValuesPlugin.md5 manage 180 bytes 30 Jul 2015 - 16:21 Main.KennethLavrsen  
SetFormValuesPlugin.sha1sha1 SetFormValuesPlugin.sha1 manage 204 bytes 30 Jul 2015 - 16:21 Main.KennethLavrsen  
SetFormValuesPlugin.tgztgz SetFormValuesPlugin.tgz manage 8 K 30 Jul 2015 - 16:20 Main.KennethLavrsen  
SetFormValuesPlugin.zipzip SetFormValuesPlugin.zip manage 10 K 30 Jul 2015 - 16:19 Main.KennethLavrsen  
SetFormValuesPlugin_installerEXT SetFormValuesPlugin_installer manage 4 K 30 Jul 2015 - 16:20 Main.KennethLavrsen  
Topic revision: r2 - 30 Jul 2015, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy