Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
Calculated (Scripted) Labels custom field type
A calculated (scripted) custom field type that displays labels calculated using a Groovy script.
Add a Calculated (scripted) Labels custom field type
To add a Calculated (scripted) Label custom field type to your instance:
Log in to Jira as an administrator.
Click the Administration icon on the top right corner of the page.
Click
Issues - > Custom fields.
Click
Add custom field
. The Select field type dialog is displayed where you can add a custom field type.Click
Advanced
in the left panel.Locate
Calculated (scripted) Labels Field (JMCF app)
and select it.Click
Next
. You are navigated to the Configure 'Calculated (scripted) Labels Field (JMCF app)' field dialog.Provide a name for the custom field.
You can optionally provide a description of the custom field.
Click
Next.
You are navigated to the Configure context dialog.Configure the following:
Select issue types: Select the issue types for which the custom field is enabled.
Choose context: Select one of the following:
Apply to issues in selected projects (Recommended option): Creates a custom field only in issues that belong to projects specified in Select projects. This option has a low impact on the indexing time.
Apply to all issues on your instance: Creates a custom field for all the issues on your Jira instance. This option has a great impact on the indexing time.
Click
Create
to create the custom field.Click ellipsis under the Action column of the custom field and select:
Screens
to associate the custom field to appropriate screens.Configure
to create a formula (explained in Configuration details) for the custom field.
You can create multiple contexts if you need to associate different formulas with particular projects or issue types.
Perform a re-index as prompted by JIRA.
- 1 Add a Calculated (scripted) Labels custom field type
- 1.1 Related links
- 2 Configuration details
- 2.1 Configure the Groovy formula for a Calculated (scripted) Labels custom field type
- 2.2 Customize the search template
- 2.3 Customize the display of the Calculated (scripted) Label custom field type value on the issue detail view
- 2.4 Customize the display of the Calculated (scripted) Label custom field type value on the search list view
- 2.5 Display the Calculated (scripted) Label custom field type on Transition and Edit screen
Related links
Writing scripts in JMCF using the Groovy language
Upgrade from 1.x to 2.x guide
Configuration details
Configure the Groovy formula for a Calculated (scripted) Labels custom field type
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"
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 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:
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 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.