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

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 custom field 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("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 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("Cascading type field 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:get(". Each level is a LazyLoadedOption. You can access the field using:
    • get("Your custom field 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
        languagegroovy
        issue.get("Single-group picker name")?.find() { it.getName() == "Group name" } != null
      getAsString("
      • 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("MLCS field")?.first()


    • 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

  • 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:
    linenumberstrue
    issue.get("
    Multi
    • Single-group picker name")?.find() { it.getName() == "Group name" } != null


  • getAsString("Your custom field 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")
  • Users



    Panel
    borderStylesolid
    Single

    Multi-

    User picker

    Group Picker

    Multi-user picker

    • Description: A field of multi-user picker type is an array of objects. Each user is an object in itself
        • Example: Is a specific group selected?

          Code Block
          languagegroovy
          linenumberstrue
          issue.
      • getAsString
        • get("
      • Single
        • Multi-
      • user
        • group picker 
      • field
        • name"
      • )
    Panel
    borderStylesolid

    Users

    Panel
    borderStylesolid

    Single-User picker

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

    • Accessing a field of MultiSingle-user picker typeYou can access a custom field of MultiSingle-user picker type using any of the following getters of the Issue interface:


    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:


    true
  • issue.get("Your custom field name") .size()or get("customfield_xxxxx")that returns a String
    • Example:

      All the Watchers in the custom field except the Reporter

      Text of the field

  • 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 Multi-line text type is a string that represents a multi-line text.

    • Accessing a field of Watchers 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 custom field name") or get("customfield_xxxxx") that returns a Collection<ApplicationUser>Example:Number of Watchers in the custom field
    Code Block
    languagegroovy
    linenumbers
    Code Block
    languagegroovy
    linenumberstrue
    issue.get("
    Your
    Multi-line 
    custom
    text field name
    ")?.findAll { it.getName() != issue.get(
    "
    reporter"
    )
    .getName() }


  • getAsString("Your custom field 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 custom Watchers
      Multi-line text field name")
  • Versions




    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


    Panel
    borderStylesolid
    Single-line text field type

    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: String text:
      • Number
        • Example:

        Text
        • Value of the numeric field

          Code Block
          languagegroovy
          linenumberstrue
          issue.getAsString("
        Multi-line
        • Numeric 
        text
        • field 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

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

      Access a field of Date picker type

       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 Date Project picker type using any of the following getters of the Issue interface:

    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

    • 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 Date time picker Checklist type: You can access a custom field of Date time picker Checklist type using any of the following getters of the Issue interface:

    Others

    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:

    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 Insight object/s 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 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:

    Add-on provided custom fields

    ...

        • .first().name



    true
  • issue.get("Checklist Your custom field name") .first().name

    Example: is a specific ChecklistItem selected?

  • 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 custom field name") or get("customfield_xxxxx") that returns a Collection<ChecklistItem>Example:
         Name of the first ChecklistItem of a checklist field
    Code Block
    languagegroovy
    linenumbers
    Code Block
    languagegroovy
    issue.get("Checklist field name")?.find{
      it.name == "test"
    }?.isChecked()

    Example: All mandatory ChecklistItem

    or get("customfield_xxxxx")that returns ObjectBean
    • Example:Name of the Insight Referenced Object (single)

      Code Block
      languagegroovy
      linenumberstrue
      issue.get("Checklistcustom 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
    • .name



    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: