Configuration details
Configure the Groovy formula for a Calculated (scripted) Labels custom field type
Starting from 2.0.0 BeanShell has been replaced by Groovy in the JMCF add-on. Formulae written in BeanShell will work unchanged in Groovy except for some specific cases
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:
Code Block "label1Marketing label2Sales"
Labels of the current issue:
Code Block issue.get("labels")
Label value based on the reporter:
Code Block issue.get("Reporter").username == 'msmith' ? "QA" : "DEV"
Customize the search template
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.
Customize the display of the Calculated (scripted) Label custom field type value on the issue detail view
You can define a velocity template that will return the Html 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 Stringand other variables described on this page
For example:
Code Block |
---|
<font color="red"> $value </font> |
Customize the display of the Calculated (scripted) Label custom field type value on the search list view
You can define a velocity template that will return the Html 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 Stringand other variables described on this page
For example:
|
Display the Calculated (scripted) Label custom field type on Transition and Edit screen
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.