User created custom fields
This page explains how to access the value of User-created custom fields of different field types using Groovy. You can access them using the getters of the Issue interface. However, accessing custom fields using the native Jira API can be much more complex, depending on the type of the custom field being accessed. Instead, it is easier to access the fields using the methods provided by JMCF.
'xxxxx' in the custom fields detailed below is the ID of the custom field. Click here to know how to find the ID of custom fields.
In this page:
Select list
Checkboxes / Multi-select list
Description: A Field of the type Checkboxes/Multi-select list, is an array of objects. Each selected option is an object in itself.
- Accessing a field of Checkboxes/Multi-select list type: You can access a custom field of Checkboxes/Multi-select type using any of the following getters of the Issue interface:
get("<Your custom field name>") or get("customfield_xxxxx")
that returns aCollection<Option>
Example: First selected option value of a checkbox field
issue.get("<Checkboxes field name>")?.first()?.getValue()
Example: is a specific option selected?
issue.get("<Checkboxes field name>")?.find() { it.getValue() == "An option" } != null
getAsString("<Your custom field name>") or getAsString("customfield_xxxxx")
that returns aString
with comma separated Option valuesExample: Options selected
issue.getAsString("<Checkboxes field name>")
Radio buttons / Single-select list
Description: A field of Radio buttons/Single-select list type is an object that represents an option.
- Accessing a field of Radio buttons/Single-select list type: You can access a custom field of Radio buttons/Single-select list type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
String
Example: is a specific option selected?
issue.get("<Radio button field name>") == "An option"
Example: Option value of the Single-select list
issue.get("<Single-select list field name>")
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
representing the value of the OptionExample: Option selected
issue.getAsString("<Single-select list field name>")
that returns a OptiongetRawValue("<Your custom field name>") or
getRawValue("customfield_xxxxx")
Example: Option selected
issue.getRawValue("<Single-select list field name>")
Cascading
Description: A field of Cascading type is a Map with the
Key
asString
andValue
as theOption
- Accessing a field of Cascading type: You can access a custom field of Cascading type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Map<String, Option>
Example: Parent of the cascading field
issue.get("Cascade")?.get(null)?.getValue()
Example: Return parent and child of the cascading field as Strings separated by a comma:
if (issue.get("<Cascading type field name>")) { if(issue.get("<Cascading type field name>").get("1")) { return issue.get("<Cascading type field name>").get(null).getValue() + "," + issue.get("<Cascading type field name>").get("1") } return issue.get("<Cascading type field name>").get(null).getValue() }
getAsString("<Your custom field name>") or getAsString("customfield_xxxxx")
that returns aString
with the parent and child value separated by a commaExample: Return parent and child of the cascading field as Strings separated by a comma:
issue.getAsString("<Cascading type field name>")
Groups
Single-Group Picker
Description: A field of Single-group picker type is an object that represents a group.
- Accessing a field of Single-Group picker type: You can access a custom field of Single-group picker type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Collection
<Group>
Example: Name of the first selected group
issue.get("<Single-group picker name>")?.first()?.getName()
Example: Is a specific group selected?
issue.get("<Single-group picker name>")?.find() { it.getName() == "Group name" } != null
that returns a String representing the group name:getAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
Example: Name of the selected group
issue.getAsString("<Single-group picker name>")
Multi-Group Picker
Description: A field of Multi-group picker is an array of objects. Each group is an object in itself.
- Access a field of Multi-group picker type: You can access a custom field of Multi-group picker type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Collection
<Group>
Example: Name of the first selected group
issue.get("<Multi-group picker name>")?.first()?.getName()
Example: Is a specific group selected?
issue.get("<Multi-group picker name>")?.find() { it.getName() == "Group name" } != null
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
with comma separated Group namesExample: Groups selected
issue.getAsString("<Multi-group picker name>")
Users
Single-User picker
Description: A field of Single-user picker is an object that represents a user.
- Accessing a field of Single-user type: You can access a custom field of Single-user picker type using any of the following getters of the Issue interface:
that returns anget("<Your custom field name>") or
get("customfield_xxxxx")
ApplicationUser
Example: Email Address of the user selected in the field
issue.get("<Single-user picker field name>")?.getEmailAddress()
getAsString("<Your custom field name>") or getAsString("customfield_xxxxx")
that returns aString
representing the usernameExample: User selected in the field
issue.getAsString("<Single-user picker field name>")
Multi-user picker
Description: A field of multi-user picker type is an array of objects. Each user is an object in itself.
- Accessing a field of Multi-user picker type: You can access a custom field of Multi-user picker type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Collection
<ApplicationUser>
Example: Is the reporter of the issue selected?
issue.get("<Multi-user picker field name>")?.find() { it.getName() == issue.get("reporter").getName() } != null
Example: Email address of all the selected users:
def EmailId = [] issue.get("MUP")?.findAll() { EmailId.push(it.getEmailAddress()) } return EmailId
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
with comma separated Usernames.Example: All the selected users:
issue.getAsString("<Multi-user picker field name>")
Watchers field type
Description: A field of the Watchers type is an array of objects. Each user is an object in itself.
- Accessing a field of Watchers field type: You can access a custom field of Watchers field type using any of the following getters of the Issue interface:
get("<Your custom field name>") or get("customfield_xxxxx")
that returns aCollection
<ApplicationUser>
Example: Number of Watchers in the custom field
issue.get("<Your custom field name>").size()
Example: All the Watchers in the custom field except the Reporter
issue.get("<Your custom field name>")?.findAll { it.getName() != issue.get("reporter").getName() }
getAsString("<Your custom field name>") or
that returns agetAsString("customfield_xxxxx")
String
with comma separated Usernames.Example: All Watchers in the custom field
issue.getAsString("<Your custom Watchers field name>")
Versions
Single-version picker
Description: A field of Single-version picker type is an object that represents a version.
- Accessing a field of Single-Version picker type: You can access a custom field of Single-version picker type using any of the following getters of the Issue interface
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Collection
<Version>
Example: Release date of the selected version:
issue.get("<Single-Version picker field name>")?.last()?.getReleaseDate()
that returns a String representing the name of the version:getAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
Example: Release date of the selected version:
issue.getAsString("<Single-Version picker field name>")
Multi-version picker
Description: A field of Multi-version picker type is an array of objects. Each version is an object in itself.
- Accessing a field of Multi-version picker type: You can access a custom field of Multi-version picker type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Collection
<Version>
Example: Are the selected versions same as the Affects Version/s?
issue.get("<Multi-Version picker field name>") == issue.get("versions")
Example: Release date of the last versions
issue.get("<Multi-Version picker field name>")?.last()?.getReleaseDate()
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
with comma separated Version namesExample: Selected versions:
issue.getAsString("<Multi-Version picker field name>")
Text
Single-line text field type
Description: A field of Single-line text type is a string that represents a single-line text.
- Accessing a field of Single-line text field type: You can access a custom field of Single-line text type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
String
Example: Text of the field
issue.get("<Single-line text field name>")
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
representing the text:Example: Text of the field
issue.getAsString("<Single-line text field name>")
Multi-line text field type
Description: A field of Multi-line text type is a string that represents a multi-line text.
- Accessing a field of Multi-line text field type: You can access a custom field of Multi-line text type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
String
Example: Text of the field
issue.get("<Multi-line text field name>")
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
representing the text:Example: Text of the field
issue.getAsString("<Multi-line text field name>")
Read-only text field type
Description: A field of Read-only text type is a string that represents a read-only text.
- Accessing a field of Multi-line text field type: You can access a custom field of Read-only text type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
String
Example: Text of the field
issue.get("<Read-only text field name>")
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
representing the text:Example: Text of the field
issue.get("<Read-only text field name>")
Date/Time picker
Date picker
Description: A field of Date picker type is a Timestamp (Date) object.
- Access a field of Date picker type: You can access a custom field of Date type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Timestamp
Example: The value of the Date picker type field
issue.get("<Date picker field name>")
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
representing the date:Example: The value of the Date picker type field
issue.getAsString("<Date picker field name>")
To manipulate the date see here
Date time picker
Description: A field of Date time picker type is a Timestamp (Date) object.
- Accessing a field of Date time picker type: You can access a custom field of Date time picker type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Timestamp
Example: return the date without the time value (or rather at 00:00:00)
issue.get("<Date picker field name>").clearTime()
that returns a String representing the date-time:getAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
Example: Date time picker value
issue.getAsString("<Date picker field name>")
To manipulate the date see here
Others
Numeric field
Description: A field of Numeric type is a number.
- Accessing a field of Numeric type: You can access a custom field of Numeric type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Double
Example: Value of the numeric field
issue.get("<Numeric field name>")
that returns a String representing the NumbergetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
Example: Value of the numeric field
issue.getAsString("<Numeric field name>")
Project picker type
Description: A field of Project picker type is an object describing a project.
Accessing a field of Project picker type: You can access a custom field of Project picker type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
Project
Example: Is the project same as the project the current issue belongs to?
issue.get("<Project picker type field name>") == issue.get("project")
that returns a String representing the key of the project:getAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
Example: Name of the project picked:
issue.getAsString("<Project picker type field name>")
URL field type
Description: A field of URL type is a string representation of an URL
- Accessing a field of URL type: You can access a custom field of Project picker type using any of the following getters of the Issue interface:
that returns aget("<Your custom field name>") or
get("customfield_xxxxx")
String
Example: URL value
issue.get("<URL type field name>")
that returns agetAsString("<Your custom field name>") or
getAsString("customfield_xxxxx")
String
representing the URLExample: URL value
issue.get("<URL type field name>")