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

Multi-level Cascading select

  • Description: A field of Single-group picker type Multi-level Cascading select is an object that represents a group.multiple levels of parent and child options

  • Accessing a field of Single-Group picker Multi-level Cascading select type: You can access a custom field of Single-group picker Multi level Cascading select type using any of the following getters of the Issue interface:. Each level is a LazyLoadedOption. You can access the field using:
    • get("<Your Your custom field name>name") or get("customfield_xxxxx") that returns a Collection<Group>an array of LazyLoadedOption
      • Example:Name of the first selected group 

        Code Block
        languagegroovy
        issue.get("<Single-group picker name>")?.first()?.getName()

        Example: Is a specific group selected?

        Code Block
        MLCS field")

        returns ["A","A1","A2"] where A, A1 and A2 are the values in the three levels of the field.

      • Example: To get the first level option of the Multi-level cascading select field

        Code Block
        languagegroovy
        issue.get("<Single-group picker name>MLCS field")?.findfirst() { it.getName() == "Group name" } != null
      getAsString("<Your custom field name>") or

    • getAsString("Your custom field name") or getAsString("customfield_xxxxx") that returns a String

      representing the group name:

       with comma-separated values of multiple levels of the field.

      • Example:Name of the selected group Return the option value of the last level of a Multi-level cascading select field:

        Code Block
        languagegroovy
        issue.getAsString("<Single-group picker name>")
Panel
borderStylesolid
Multi
      • MLCS field")

        returns A,A1,A2 where A, A1 and A2 are the values in the three levels of the field.

Groups

true
  • Panel
    borderStylesolid

    Single-Group Picker

    • Description: A field of MultiSingle-group picker type is an array of objects. Each group is an object in itself.

      Access

      object that represents a group.

    • Accessing a field of MultiSingle-group Group picker type:  You can access a custom field of MultiSingle-group picker type using any of the following getters of the Issue interface:
    linenumbers
    issue.get("
    <Multi
    • Single-group picker 
  • name>
    • name")?.find() { it.getName() == "Group name" } != null


  • getAsString("

    <Your

    Your custom field

    name>

    name") or getAsString("customfield_xxxxx")that returns a String

    with comma separated Group names

    representing the group name:

    • Example:

      Groups

      Name of the selected group

      Code Block
      languagegroovylinenumberstrue
      issue.getAsString("<MultiSingle-group picker name>name")
  • Users



    Panel
    borderStylesolid
    Single

    Multi-

    User picker

    Group Picker

    • Description: A field of SingleMulti-user picker group picker is an array of objects. Each group is an object that represents a userin itself.

    • Accessing Access a field of SingleMulti-user group picker typeYou can access a custom field of SingleMulti-user group picker type using any of the following getters of the Issue interface:
        • Example: Is a specific group selected?

          Code Block
          languagegroovy
          linenumberstrue
          issue.
      • getAsString
        • get("
      • <Single
        • Multi-
      • user
        • group picker 
      • field name>")
    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:

    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

    • Description: A field of Single-version picker type is an object that represents a version.

    • Accessing a field of Single-Version picker typeYou can access a custom field of Single-version picker type using any of the following getters of the Issue interface


    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:
        • Example: Release date of the last versions

          Code Block
          languagegroovy
          linenumberstrue
          issue.get("Multi-Version picker field name")?.last()?.getReleaseDate()


      • getAsString("Your custom field name") or getAsString("customfield_xxxxx") that returns a String with comma separated Version names

        • Example: Selected versions:

          Code Block
          languagegroovy
          linenumberstrue
          issue.getAsString("Multi-Version picker field name")


    Text

    Panel
    borderStylesolid

    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:


    Panel
    borderStylesolid
    Watchers

    Multi-line text field type

    • Description: A  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

      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 Watchers field type Multi-line text 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<ApplicationUser> String
      • Example:

        Number of Watchers in the custom field
        Code Block
        languagegroovy
        linenumberstrue
        issue.get("<Your custom field name>").size()
        Example: All the Watchers in the custom field except the Reporter

        Text of the field

        Code Block
        languagegroovy
        linenumberstrue
        issue.get("
        <Your
        Multi-line 
        custom
        text field 
        name>")?.findAll { it.getName() != issue.get("reporter").getName() }
        name")


    • getAsString("

      <Your

      Your custom field

      name>

      name") or

       

      getAsString("customfield_xxxxx")

       

      that returns

       String with comma separated Usernames.

      a

       

      Stringrepresenting the text:

      • Example:

        All Watchers in

        Text of the

        custom

        field

        Code Block
        languagegroovy
        linenumberstrue
        issue.getAsString("
        <Your
        Multi-line 
        custom
        text 
        Watchers
        field 
        name>
        name")

    ...




    Panel
    borderStylesolid
    Single-version picker

    Read-only text field type

    • Description: A field of SingleRead-version picker only text type is an object a string that represents a versiona read-only text.

    • Accessing a field of Single-Version picker Multi-line text field type:   You can access a custom field of SingleRead-version picker only text type using any of the following getters of the Issue interface:

    Date/Time picker

    Panel
    borderStylesolid
    Multi-version

    Date 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

      of Date picker type is a Timestamp (Date) object.

    • Access a field of Date picker typeYou can access a custom field of Multi-version picker Date type using any of the following getters of the Issue interface:

    ...

        • To manipulate the date see here


    Single-line text field type
    Panel
    borderStylesolid

    Date time picker

    • Description: A field of Single-line text type is a string that represents a single-line textof Date time picker type is a Timestamp (Date) object.

    • Accessing a field of Single-line text field Date time picker type:You  You can access a custom field of Single-line text Date time picker type using any of the following getters of the Issue interface:

    Others

    Panel
    borderStylesolid
    Multi-line text

    Numeric field

    type

    • Description: A field of Multi-line text Numeric type is a string that represents a multi-line textnumber.

    • Accessing a field of Multi-line text field Numeric type: You can access a custom field of Multi-line text Numeric type using any of the following getters of the Issue interface:<Your name> String
      • Double
        • Example:

        Text
        • Value of the numeric field

          Code Block
          languagegroovy
          linenumberstrue
          issue.get("
        <Multi-line
        • Numeric 
        text
        • field 
        name>
        • name")


      • getAsString("
      <Your name> text:
      • Number
        • Example:

        Text
        • Value of the numeric field

          Code Block
          languagegroovy
          linenumberstrue
          issue.getAsString("
        <Multi-line
        • Numeric 
        text
        • field 
        name>
        • name")



    Panel
    borderStylesolid
    Read-only text field

    Project picker type

    • Description: A field of Read-only text Project picker type is a string that represents a read-only textan object describing a project.

    • Accessing a field of

      Multi-line text field

      Project picker type: You can access a custom field of

      Read-only text

      Project picker type using any of the following getters of the Issue interface:

    ...



    Panel
    borderStylesolid
    Date picker

    URL field type

    Add-on provided custom fields

    Checklist for Jira

    Panel
    borderStylesolid

    Date time picker

    Description: A field of Date time picker type is a Timestamp (Date) object

    Checklist

    Panel
    borderStylesolid

    Numeric field

    • Description: A field of Numeric type is a number.

    • Accessing a field of Numeric typeYou can access a custom field of Numeric type using any of the following getters of the Issue interface:
      • get("<Your custom field name>") or get("customfield_xxxxx") that returns a Double

        Example: Value of the numeric field

        Code Block
        languagegroovy
        linenumberstrue
        issue.get("<Numeric field name>")
        getAsString("<Your custom field name>
        • Example: Date time picker value
          first().name


        • Example: is a specific ChecklistItem selected?

          Code Block
          languagegroovylinenumberstrue
          issue.getAsStringget("<DateChecklist picker field name>")

          To manipulate the date see here

    Others

        • name")?.find{
            it.name == "test"
          }?.isChecked()


        • Example: All mandatory ChecklistItem

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


        • Example: Print all the names of the ChecklistItems

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


      • getAsString("Your custom field name") or getAsString("customfield_xxxxx")that returns a String

        representing the Number

        with comma separated ChecklistItem

        • Example: Value of the numeric fieldAll Checklist item

          Code Block
          languagegroovylinenumberstrue
          issue.getAsString("<NumericChecklist field name>name")


    Insight custom fields

    Panel
    borderStylesolid
    Project picker type

    Insight Object/s

    • Description:  A A recommended Insight field of Project picker type is an object describing a projectthe type Insight Object/s that supports both single and multiple values.

    • 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:

      get("<Your custom field name>") or get("customfield_xxxxx") that returns a Project

      Example: Is the project same as the project the current issue belongs to?

      Code Block
      languagegroovy
      linenumberstrue
      issue.get("<Project picker type field name>") == issue.get("project")
      getAsString("<Your custom field name>") or getAsStringInsight object/s type: You can access a custom field of Insight object/s type using any of the following getters of the Issue interface:


    Panel
    borderStylesolid
    URL field type

    Insight Readonly Object/s

    • Description:   A field of URL type is a string representation of an URLthe type Insight Readonly Object/s that displays Insight Object/s.

    • You

      Accessing a field of

      URL type:

      Insight Readonly Object/s: You can access a custom field of

      Project picker type using

      the Insight Readonly Object/s type using any of the following getters

      of the Issue interface:get("<Your custom field name>") or get("customfield_xxxxx") that returns a String

      Example: URL value

      Code Block
      languagegroovy
      linenumberstrue
      issue.get("<URL type field name>")
      getAsString("<Your custom field name>") or getAsString

      of the Issue interface:

    Add-on provided custom fields

    ...

        • name").first().name



    Panel
    borderStylesolid
    Checklist

    Insight Referenced Object (single)

    • Description: A Field of the type Checklist, is an array of Check list items. Each selected ChecklistItem is an object in itselfA field of the type Insight Referenced Object (single) that connects Insight Object/s referenced from another Insight Custom Field.

    • Accessing a field of Checklist typeof Insight Referenced Object (single): You can access a custom field of Checklist type using the Insight Referenced Object (single) 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>returns ObjectBean
        • Example: Name of the first ChecklistItem of a checklist fieldName of the Insight Referenced Object (single)

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

          Example: is a specific ChecklistItem selected?

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

          Example: All mandatory ChecklistItem

          Code Block
          languagegroovy
          issue.get("<Checklist field name>")?.findAll{
            it.mandatory == true
          }
        getAsString("<Your custom field name>") or getAsString


    Panel
    borderStylesolid

    Insight Referenced Object (multiple)

    • Description: A field of the type Insight Referenced Object (multiple) that connects Insight Objects referenced from another Insight Custom Field.

    • Accessing a field of Insight Referenced Object (multiple): You can access a custom field of the Insight Referenced Object (multiple) type using any of the following getters of the Issue interface: