Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 JMWE. To understand how to write values into the writable custom fields see Raw value/text input for fields and Groovy expression input for fields

...

Panel
borderStylesolid

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:


Panel
borderStylesolid

Radio buttons / Single-select list


Panel
borderStylesolid

Cascading

  • Description: A field of Cascading type is a Map with the Key as String and Value as the Option

  • 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:
    • get("<Your Your custom field name>name") or get("customfield_xxxxx") that returns a Map<StringOption>
      • Example: Parent of the cascading field

        Code Block
        languagegroovy
        issue.get("Cascade")?.get(null)?.getValue()


      • Example: Return parent and child of the cascading field as Strings separated by a comma:

        Code Block
        languagegroovy
        if (issue.get("<CascadingCascading type field name>name"))
        {
          if(issue.get("<CascadingCascading type field name>name").get("1"))
          {
            return issue.get("<CascadingCascading type field name>name").get(null).getValue() + "," + issue.get("<CascadingCascading type field name>name").get("1") 
          }
          return issue.get("<CascadingCascading type field name>name").get(null).getValue()
        }


    • getAsString("<Your Your custom field name>name") or getAsString("customfield_xxxxx") that returns a String with the parent and child value separated by a comma

      • Example: Return parent and child of the cascading field as Strings separated by a comma:

        Code Block
        languagegroovy
        issue.getAsString("<CascadingCascading type field name>name")


Groups

Panel
borderStylesolid

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:


Panel
borderStylesolid

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 typeYou can access a custom field of Multi-group picker type using any of the following getters of the Issue interface:

Users

Panel
borderStylesolid

Single-User picker


Panel
borderStylesolid

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 typeYou can access a custom field of Multi-user picker type using any of the following getters of the Issue interface:


Panel
borderStylesolid

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 typeYou can access a custom field of Watchers field type using any of the following getters of the Issue interface:

Versions

Panel
borderStylesolid

Single-version picker


Panel
borderStylesolid

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 typeYou can access a custom field of Multi-version picker type using any of the following getters of the Issue interface:

Text

Panel
borderStylesolid

Single-line text field type


Panel
borderStylesolid

Multi-line text field type


Panel
borderStylesolid

Read-only text field type

Date/Time picker

Panel
borderStylesolid

Date picker

...

Panel
borderStylesolid

Date time picker

...

Panel
borderStylesolid

Numeric field


Panel
borderStylesolid

Project picker type


Panel
borderStylesolid

URL field type

Add-on provided custom fields

...

Panel
borderStylesolid

Checklist

  • Description: A Field of the type Checklist, is an array of Check list items. Each selected ChecklistItem is an object in itself.

  • Accessing a field of Checklist type: You can access a custom field of Checklist type using any of the following getters of the Issue interface:
    • get("<Your Your custom field name>name") or get("customfield_xxxxx") that returns a Collection<ChecklistItem>
      • Example: Name of the first ChecklistItem of a checklist field

        Code Block
        languagegroovy
        linenumberstrue
        issue.get("<ChecklistChecklist field name>name").first().name


      • Example: is a specific ChecklistItem selected?

        Code Block
        languagegroovy
        issue.get("<ChecklistChecklist field name>name")?.find{
          it.name == "test"
        }?.isChecked()


      • Example: All mandatory ChecklistItem

        Code Block
        languagegroovy
        issue.get("<ChecklistChecklist field name>name")?.findAll{
          it.mandatory == true
        }


      • Example: Print all the names of the ChecklistItems

        Code Block
        languagegroovy
        <% def count = 0
        issue.get("<ChecklistChecklist field name>name").each() {
          count++
          print "Checklist Item " + count + ": " + it.name + "\n"
        }
        %>


    • getAsString("<Your Your custom field name>name") or getAsString("customfield_xxxxx")that returns a String with comma separated ChecklistItem

      • Example: All Checklist item

        Code Block
        languagegroovy
        issue.getAsString("<ChecklistChecklist field name>name")