To write a formula for the Calculated (scripted) Label custom field type;
Locate the custom field on the Custom Fields administration page.
Click the ellipsis under the Action column of the respective custom field and select Configure
to create a formula for the field.
Click Edit Groovy Formula.
In the editor write a Groovy script that returns a String representing a single/multi-line text. Also, you can test your script against any issue using the Groovy script tester.
Click Save.
As documented on the Expected Value tab of the Groovy help editor, the Groovy formula must return one of the following values:
A space-separated list of labels. "label1 label2"
An array of labels: ["label1", "label2"]
A Set of Label objects
Examples:
A space-separated list of labels:
"Marketing Sales" |
Labels of the current issue:
issue.get("labels") |
Label value based on the reporter:
issue.get("Reporter").username == 'msmith' ? "QA" : "DEV" |
When creating a Calculated (scripted) Label custom field type, you can configure the Search template as Labels Searcher (Statistics-compatible). This is a custom statistics-compatible searcher provided by JMCF that searches for values matching labels. If you select “None” for the searcher, you won’t see any reference to this field in the Issue Navigator search fields.
Note that changing a custom field searcher requires a re-index.
You can define a velocity template that will return the HTML representation of the calculated custom field on the issue detail view, in addition to the formatting provided in the custom field value. Leave it empty to use the default template.
To select a format for a Calculated (scripted) Label custom field type value;
Locate the custom field on the Custom Fields administration page.
Click the ellipsis under the Action column of the respective custom field and select Configure
to create a formula for the field.
Click Edit Velocity Template
.
Input the template.
Click Save.
You can use the following Velocity variables in the template:
$value
: the raw field value a String
$formattedValue
: a String
and other variables described on this page
For example:
<font color="red"> $value </font> |
You can define a velocity template that will return the HTML representation of the calculated custom field on the search list view, in addition to the formatting provided in the custom field value. Leave it empty to use the default template.
To select a format for a Calculated (scripted) Label custom field type value;
Locate the custom field on the Custom Fields administration page.
Click the ellipsis under the Action column of the respective custom field and select Configure
to create a formula for the field..
Click Edit List View Velocity Template
.
Input the template.
Click Save.
You can use the following Velocity variables in the template:
$value
: the raw field value a String
$formattedValue
: a String
and other variables described on this page
For example:
|
The Never show on Transition and Edit screens
option controls whether the Calculated (scripted) Label custom field can appear on transition and edit screens. If you select this option, the field will not be visible on any Edit or Transition screen, even if it is added to the screen.