In versions previous to 2.1.16, this post-function was called "Set a field from a set of rules based on regular expressions".
Post-function Set a field as a function of other fields is used for updating the value of a field depending on the value of other fields in the issue, by means of a set of setting rules.
Each setting rule is formed by a pair condition-value. There are two types of setting rules:
Setting rules are evaluated in the same order they are written (one rule per line), and the evaluation stops at first rule matching. The resulting value is copied into target field and the rest of the rules are skipped.
Both kinds of setting rules (type 1 and type 2) can be combined in a same post-function.
The following screenshot shows an example of post-function configuration for setting issue Priority depending on fields Components and Original estimate.
It must be taken into account that multi-select fields (like Components) return a list of comma separated values, e.g., Component B, Component D, Component E, and field "Original estimate (minutes)" (field code {00068}) returns the number of minutes estimated for resolving the issue.
This example combines both types of setting rules:
The behavior implemented by this example is:
Note that:
You have previously set the default user for each project role, the same way as in post-function Assign to project role
Once configured, Create Issue transition would look like this:
We use the following criteria:
We have 5 priorities, with a numeric value associated to each one of them: Blocker (0), Critical (1), Major (2), Minor (3) and Trivial (4).
In this example parameter field to be checked hasn't any function since we are not using setting rules with regular expressions:
Note that:
Once configured, Create Issue transition would look like this:
Field whose value is going to be evaluated against regular expressions in the setting rules. The first matched regular expression will stop the evaluation of the remaining ones, and its associated setting value will be written into Target field.
Field that will be set by the post-function. Its type will determine whether the expected Setting value is a math-time formula (when Target field is a Number, Date or Date-Time), or a parsed text (in the rest of cases).
This parameter is a multiline text field containing one setting rule per line. There are 2 types of setting rules, with the following formats:
Value part of the setting rules: is written just after the closing bracket character (')' for type 1 rules, or ']' for type 2 rules). It represents the value to be written into Target field when its associated regular expression is matched by the value stored in field to be checked, or the boolean expression is evaluated as true.
The value part of the setting rules can be a parsed text or a math-time formula depending on the type of Target field to be set:
Optional prefixes are single characters that can preceed setting rules for changing someway its behavior:
When this parameter is unchecked, once a setting rule is matched, the rest of setting rules are discarded, but when checked, all setting rules are evaluated, and this way all value assignments of matching rules are executed. This checkbox is by default unchecked, and only enabled and allowed to be checked, when target field is a multi-valued field, i.e., fields that can contain more than one value: Multi-Select, Checkbox, Multi-User picker, Multi-Group picker, Affected versions, Fixed versions, Components, Labels, Issue picker and Attachments.
Even if you have poor knowledge about regular expressions you can find this post-function very useful knowing that a string composed exclusively by letters, spaces, and numbers is a regular expression that matches itself, e.g., if you have a custom field of type select list called Colour with options red, yellow, green and blue, you can evaluate for its selected value using simple setting rules like: (red)value_for_red, (yellow)value_for_yellow, (green)value_for_green and (blue)value_for_blue
.
Example: Set a custom field "Urgency" depending on a combined value of issue's Priority and "Impact" custom field.
If none of the setting rules is matched by the value in Field to be checked the Target field will not be set. If you need to ensure that Target field is set in all cases, you should insert as last setting rule something like (.*)setting_value. This rule works as the ELSE clause in a classic IF-THEN-ELSE sentence, since it is evaluated only once all the previous setting rules have been evaluated and not matched, and the regular expression "(.*)" matches any string, even an empty one.
When you need to make the conditional part of a setting rule dependent of more than one field, you should use type 2 setting rules. For example, if you need to "activate" a rule when issue type is Bug and Resolution is Duplicated, you can use the following setting rule:[%{00014}="Bug" and %{00028}="Duplicated"]value_to_be_assigned
, where %{00014} is field code for "Issue type" and %{00028} is the field code for "Resolution".
What we have described in this page is the basic functionality of the post-funcion, but you can combine it with other post-functions to attain more complex functionalities: