Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Groovy expression input for fields

This document lists the expected result of a Groovy expression that should be provided to set Jira Standard and Custom fields. The easiest is to use the "Expected Value" tab of the Groovy editor help system. It lists the possible expected values for the selected Field and Value Type. This is applicable in contexts where you set a field value or comment an issue or write a conditional Groovy script. Select the Field and Value Type as Set field value to Groovy expression. Click on Expected Value. The help editor displays the expected values for the selected field.

You might also want to look at Standard fieldsPredefined custom fields, and User-created custom fields to know how to access the fields of an issue object.

On this page:


Standard Jira fields

 Field Name

Expected input type

Expected input value

Example

Affects Version/s

String

String[]

Version

Collection<Version>

A Groovy expression that returns a:

  1. String representing the name or id of a version.
  2. String with comma separated values that represent the names or ids (id takes precedence over the name) of the versions
  3. An array of strings that represent the names or ids (id takes precedence over the name) of the versions
  4. Single version object
  5. Collection of version objects
  1. "1.0"
  2. "1.0,2.0"
  3. ["1.0","2.0"]
  4. On creating a Bug set its Affects Version/s to the most recently released version

  5. Set the Affects Version/s of the issue to Affects Version/s of all its linked issues
Assignee

String

ApplicationUser

A Groovy expression that returns a:

  1. String representing the username of a user
  2. ApplicationUser object
  1. "carter"
  2. Assign the issue to the Project lead, if the issue is unassigned on creation.
Components

String

String[]

ProjectComponent

Collection<ProjectComponent>

A Groovy expression that returns a:

  1. String representing the name or id of the component
  2. String with comma separated values that represent the names or ids (id takes precedence over the name) of the components
  3. An array of strings that represent the names or ids (id takes precedence over the name) of the components
  4. Single component object
  5. Collection of component objects
  1. On creating an issue, pick the component of the issue from a cascading field that carries the Main and Sub-components
  2. "C1,C2"
  3. ["C1","C2"]

  4. Set the Component/s of the issue to components whose lead is the current user
DescriptionString

A Groovy expression that returns a:

  1. String representing a single line text.
  2. String representing a multi-line text
  1. "Issue associated to TEST-121"
  2. "Issues:\nFirst issue\nSecond issue"

  3. On the creation of a sub-task add its summary to the description of its parent.

Due date

String

Timestamp

A Groovy expression that returns a:

  1. Set the due date to today's date

  2. Set the due date to issue created plus five days.
EnvironmentString

A Groovy expression that returns a:

  1. String representing a single line text
  2. String representing a multi-line text
  1. "QA"
  2. "1. QA\n2. Production"
Fix Version/s

String

String[]

Version

Collection<Version>

A Groovy expression that returns a:

  1. String representing the name or id of the version
  2. String with comma separated values that represent the names or ids (id takes precedence over the name) of the versions
  3. An array of strings that represent the names or ids (id takes precedence over the name) of the versions
  4. Single version object
  5. Collection of version objects
Issue type

String

Long

IssueType

Use with caution!

Changing the issue type should only be done if the current and new issue types share the same workflow, or if the issue's Status exists in both the current and new workflow. Otherwise, the operaton will fail.

Also, when changing the issue type of the current issue, make sure to move the post-function below the "Set issue status to the linked status of the destination workflow step" built-in post-function.

A Groovy expression that returns a:

  1. String representing a valid issue type name
  2. Number representing a valid issue type ID
  3. IssueType object.
  1. "Bug"
  2. 10020
  3. issue.issuetype
Labels

String

Set<Label>

A Groovy expression that returns a:

  1. String representing a value
  2. String with space separated values
  3. An array of strings that represent values
  4. Set of labels
  1. "New"
  2. "KB How-to-do"
  3. ["KB","How-to-do"]
  4. issue.get("Custom labels field")
Original Estimate

Long

String

A Groovy expression that returns a

  1. Number in Long format representing the estimate in seconds
  2. Duration string
Priority

String

Priority

A Groovy expression that returns a:

  1. String representing the name or id of the priority
  2. Priority object
  1. "Blocker"
  2. Set the priority of the issue to Highest if the issue belongs to the "Customer Portal" component

  3. On the creation of a Story, change its priority to that of the Epic if the Epic's priority is lower than the current priority of the Story

Remaining Estimate

Long

String

A Groovy expression that returns a

  1. Number in Long format representing the estimate in seconds
  2. Duration string
  • 22400L
  • "22400"
  • issue.get("timespent")
  • "4w 2d 6h 40m"
Reporter

String

ApplicationUser

A Groovy expression that returns a:

  1. String representing the username of a user
  2. ApplicationUser object
  1. "carter"
  2. Assign a reopened issue to the last person who commented it.
Resolution

String

Resolution

A Groovy expression that returns a:

  1. String representing the name or id of the resolution
  2. Resolution object.
  1. "Done"
  2. Set with the resolution the Epic resolution.

    issue.getEpic?.get("resolution")
Security level

String

Long

IssueSecurityLevel

A Groovy expression that returns a:

  1. String representing the name or id of the security level
  2. Number in Long format representing the id of the security level
  3. Security level
  1. "QA" or "10000"

  2. 10000L

  3. Assign to the first security level of the project that can be set for an issue created in this project by the current user

SummaryString

A Groovy expression that returns a String representing a single line text

"Test of the web interface"

Time spent

Long

String

A Groovy expression that returns a

  1. Number in Long format representing the time spent in seconds
  2. Duration string
  1. 22400L
  2. "22400"
  3. "4w 2d 6h 40m
Votes

String

String[]

ApplicationUser

Collection<ApplicationUser>

A Groovy expression that returns a:

  1. String representing the username of a user
  2. String with comma separated values that represent the usernames of the users.
  3. An array of strings that represent the usernames of the users
  4. Single ApplicationUser object
  5. Collection of ApplicationUser objects
  1. "charlie"
  2. "charlie,carter"
  3. ["charlie","carter"]
Watchers

String

String[]

ApplicationUser

Collection<ApplicationUser>

A Groovy expression that returns a:

  1. String representing the username of a user
  2. String with comma separated values that represent the usernames of the users.
  3. An array of strings that represent the usernames of the users
  4. Single ApplicationUser object
  5. Collection of ApplicationUser objects
  1. "charlie"
  2. "charlie,carter"
  3. ["charlie","carter"]
  4. On the creation of a Story add the reporter of its Epic to the Watchers

Pre-defined custom fields

Capture for JIRA fields

 Field NameExpected input typeExpected input valueExamples
All Capture for JIRA fieldsString

A Groovy expression that returns a:

  1. String representing a single line text.
  2. String representing a multi-line text
  • issue.get("environment")
Raised duringStringA Groovy expression that returns a String representing the id of a session."10001"

Jira Software fields

 Field NameExpected input typeExpected input valueExamples
Epic ColorStringA Groovy expression that returns a String representing the color of the Epic.

"ghx-label-6"

Epic LinkStringA Groovy expression returning a String representing the key of an Epic.

"TEST-34"
Epic has a Story and the task has a sub-task. When the sub-task is reopened we create a bug in another project linking it to the sub-task. On creation of the Bug, set the Epic link field value to the same field of the Task

Epic NameStringA Groovy expression that returns a String representing the name of the Epic.
  • "Creation of a new issue"
  • issue.get("summary")
Epic StatusStringA Groovy expression that returns a String representing the value of the Epic status.


Sprint

Long

Sprint

Sprint[]

A Groovy expression that returns a:

  1. String representing the id of a Sprint
  2. String with comma separated values that represent the ids of the Sprints
  3. An array of strings that represent the ids of the Sprints
  4. Single Sprint object
  5. Collection of Sprint objects
  1. "1"
  2. "1,2"
  3. ["1","2"]
  4. issue.getEpic()?.get("Sprint")
Status

String

Long

Status

Use with caution!

Changing the Status of an issue is normally done only through an issue transition. Changing the Status field value directly will not validate potentially required fields (such as the Resolution field), and will leave no trace in the issue history. This should be used only in specific cases.

Also, when changing the Status of the current issue, make sure to move the post-function below the "Set issue status to the linked status of the destination workflow step" built-in post-function.

Finally, the Status field cannot be set during a Create transition.

A Groovy expression that returns a:

  1. String representing a valid status name
  2. Number representing a valid status ID
  3. Status object.
  1. "Open"
  2. 10000
  3. issue.get("status").name
Story points

String

Double

A Groovy expression that returns a:

  1. String containing a number
  2. Number in Double format.
  1. "10"
  2. 5d
  3. "25.6"

Jira Service Desk fields

 Field NameExpected input typeExpected input valueExamples
Approvers

String

String[]

ApplicationUser

Collection<ApplicationUser>

A Groovy expression that returns a:

  1. String representing the username of a user
  2. String with comma separated values that represent the usernames of the users
  3. An array of strings that represent the usernames of the users
  4. Single ApplicationUser object
  5. Collection of ApplicationUser objects
  1. "carter"
  2. "djohn,carter"
  3. ["djohn","carter"]
  4. [issue.get("assignee")]
  5. issue.get("Watchers")
Customer Request TypeString

A Groovy expression that returns a:

  • String representing the Customer Request Type name
  • String representing the Customer Request Type internal ID
  • "IT help"
  • "sd/desktoplaptopsupport"
Organizations

String

Set<String>

A Groovy expression that returns a:

  • String representing the name of an Organization
  • String representing the id of an Organization
  • String with comma-separated values that represent the names of the Organizations
  • String with comma-separated values that represent the ids of the Organizations
  • An array of strings that represent the names of the Organizations
  • An array of strings that represent the ids of the Organizations
  • "Acme, Inc."
  • "1"
  • "Acme,Apple"
  • "1,33"
  • ["Acme, Inc.", "Apple"]
  • ["1","33"]
Request Participants

String

String[]

ApplicationUser

Collection<ApplicationUser>

A Groovy expression that returns a:

    1. String representing the username of a user
    2. String with comma separated values that represent the usernames of the users
    3. An array of strings that represent the usernames of the users
    4. Single ApplicationUser object
    5. Collection of ApplicationUser objects
  • "carter"
  • "jon,charlie"
  • ["carter","djohn"]
  • issue.get("assignee")

Portfolio for Jira fields

 Field Name
Expected input type
Expected input value
Examples
Parent Link

String

A Groovy expression returning a String representing the key of an Initiative.

Note: You can use this field to create a link (Jira Portfolio Parent Link) from Epic to Initiative

"KP-9"

Tempo fields

 Field NameExpected input typeExpected input valueExamples
Account

Tempo account object

String

Long

A Groovy expression that returns either:

  • "ACCOUNT1"
  • "Account 1"
  • 23

Team

StringA Groovy expression that returns a String representing the id of the Tempo team."1"

User-created custom fields

The value expected by custom fields depends on the Custom Field Type:

Select list type

Custom field type

Expected input type

Expected input value

Examples

Checkboxes/Select List (multiple choices)

String

String[]

Option

Collection<Option>

A Groovy expression that returns a:

  1. String representing the option value or id (value takes precedence over the id)
  2. String with comma separated values that represent the values or ids (value takes precedence over the id) of options.
  3. An array of strings that represent the values or ids (value takes precedence over the id) of the options
  4. Option object
  5. Collection of option objects
  1. "10000"
  2. "Skype Installation,Eclipse Installation"
  3. ["Skype Installation","Eclipse Installation"]
  4. issue.get("Radio Buttons")

  5. Auto select the installation tasks in a Task checklist after the Installations are done.

Radio buttons/Select List (single choice)

String

Option

A Groovy expression that returns a:

  1. String representing the option value or id (value takes precedence over the id)
  2. Option object
  1. "Hipchat Installation"
  2. issue.get("Checkboxes")?.first()?.getValue()
Select List (cascading)

String

Map<String, Option>

A Groovy expression that returns a:

  1. String representing the value or id of the parent
  2. String representing the value or id of the parent and value or id of the child in the format <parent> - <child>
  3. Map with two entries
    1. null key: value or id or Option for the parent value
    2. "1" key: value or id or Option of the child
  1. "2"
  2. "1 - 1.1"
  3. [null:"O1", "1":issue.get("RB")]
Multi-level cascading select list

String

String[]

Option

Collection<Option>

A Groovy expression that returns a:

  1. A comma-separated list of option values, from parent to child: 
  2. A comma-separated list of option IDs, from parent to child
  3. An array of option values, from parent to child
  4. An array of option IDs, from parent to child: 
  5. An array of Option objects, from parent to child.
  1. "Parent 1,Child A,Child b"
  2. "10010,10011,10100"
  3. ["Parent 1","Child A","Child b"]
  4. [10010,10011,10100]
  5. issue.get("MLCS field")

Group picker

Custom field type

Expected input type

Expected input value

Examples

Group Picker (single group)

String

Group

A Groovy expression that returns a:

  1. String representing the group name
  2. Group object


Group Picker (multiple groups)

String

String[]

Group

Collection<Group>

A Groovy expression that returns a:

  1. String representing the group name
  2. String with comma separated values that represent the name of the groups
  3. An array of strings that represent the names of the groups
  4. Group object
  5. Collection of group objects
  1. "jira-administrators"
  2. "jira-administrators,jira-software-users"
  3. ["jira-administrators","jira-software-users"]
  4. issue.get("Single group")
  5. Update a custom multi-group picker field to all the groups the current user belongs to

User picker

Custom field type

Expected input type

Expected input value

Examples

User Picker (multiple users)

String

String[]

ApplicationUser

Collection<ApplicationUser>

A Groovy expression that returns a:

  1. String representing the username
  2. String with comma separated values that represent the usernames of the users
  3. An array of strings that represent the usernames of the users
  4. Single ApplicationUser object
  5. Collection of ApplicationUser objects
  1. "carter"
  2. "carter,djohn"
  3. ["carter",djohn"]
  4. issue.get("assignee")
  5. On creating an issue, Copy the component leads of the selected components to a Multi-user picker field

User Picker (single user)

String

ApplicationUser

A Groovy expression that returns a:

  1. String representing the username
  2. ApplicationUser object
  1. "carter"
  2. Save the author of the "Approve" transition in a custom single-user picker field

Version picker

Custom field type

Expected input type

Expected input value

Examples

Version Picker (single version)

String

Version

A Groovy expression that returns a:

  1. String representing the id of a version.
  2. Single version object
  1. "10000"
  2. This code snippet returns the first Fix Version/s

    issue.get("fixVersions")?.first()
Version Picker (multiple versions)

String

String[]

Version

Collection<Version>

A Groovy expression that returns a:

  1. String representing the id of a version.
  2. String with comma separated values that represent the ids of the versions
  3. An array of strings that represent the ids of the versions
  4. Single version object
  5. Collection of version objects
  1. "10000"
  2. "10000,10010"
  3. ["10000","10010" ]
  4. This code snippet returns the last Affects Version/s

    issue.get("versions")?.last()
  5. This code snippet returns the Fix Version/s

    issue.get("fixVersions")


Text

Custom field type

Expected input type

Expected input value

Examples

Text Field (single line)StringA Groovy expression that returns a String representing a single-line text.
  • "Test of a credit card issue screen"
  • issue.get("summary")
Text Field (multi line)StringA Groovy expression that returns a String representing a multi-line text.
  • "Add the post-function\nPlace it at the end"
  • issue.get("description")

Date/Time picker

Custom field type

Expected input type

Expected input value

Examples

Date Picker

String

Timestamp

A Groovy expression that returns a:

  1. String representing a timestamp in the format specified in Jira system settings.
  2. Timestamp object
Date Time PickerTimestamp

A Groovy expression that returns a:

  1. String representing a timestamp in the format specified in Jira system settings.
  2. Timestamp object
  1. "11/Apr/18 2:00 PM"
  2. issue.get("created") + 10

To manipulate the date see here

Watcher Field type

 Field Name
Expected input type
Expected input value
Examples
Watcher field type

String

String[]

ApplicationUser

Collection<ApplicationUser>

A Groovy expression that returns a:

  1. String representing the username of a user
  2. String with comma separated values that represent the usernames of the users
  3. An array of strings that represent the usernames of the users
  4. Single ApplicationUser object
  5. Collection of ApplicationUser objects
  1. "carter"
  2. "djohn,carter"
  3. ["djohn","carter"]
  4. [issue.get("assignee")]
  5. issue.get("Watchers")

Others

Custom field type

Expected input type

Expected input value

Examples

Project Picker (single project)

String

Project

A Groovy expression that returns a:

  1. String representing the project id or name or key
  2. Project object
  1. "10000"
  2. "TEST"
Labels

String

Set<Label>

A Groovy expression that returns a:

  1. String representing a value
  2. String with space separated values
  3. An array of strings that represent values
  4. Set of labels
  1. "New"
  2. "KB How-to-do"
  3. ["KB","How-to-do"]
  4. issue.get("Labels")
URL FieldStringA Groovy expression that returns a String representing a URL.

"https://innovalog.com"

Number Field

String

Double

A Groovy expression that returns a:

  1. String containing a number
  2. Number in Double format.
  • "33"
  • "100.5"
  • 20d