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

    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-

    user

    version picker

    • Description: A field of multiMulti-user version picker type is an array of objects. Each user version is an object in itself.

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

      • Email address
        • Release date of

      • all
        • the

      • selected users:
        • last versions

          Code Block
          languagegroovy
          linenumberstrue
      • def EmailId = []
        • issue.get("
      • MUP
        • Multi-Version picker field name")?.
      • findAll
        • last()
      • { EmailId.push(it.getEmailAddress()) } return EmailId
        • ?.getReleaseDate()


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

        • Example: All the selected users Selected versions:

          Code Block
          languagegroovy
          linenumberstrue
          issue.getAsString("<MultiMulti-userVersion picker field name>name")


    Text

    issue.:
    Panel
    borderStylesolid
    Watchers

    Single-line text field type

    • Description: A  A field of the Watchers type is an array of objects. Each user is an object in itself Single-line text type is a string that represents a single-line text.

    • Accessing a field of Watchers field field of Single-line text field type:  You can access a custom field of Watchers field type Single-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
    linenumberstrue
    Code Block
    languagegroovy
    linenumberstrue
    issue.get("<YourSingle-line customtext 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("<YourSingle-line customtext Watchers field name>name")
  • ...



    Panel
    borderStylesolid
    Single-version picker

    Multi-line text field type

    • Description: A field of SingleMulti-version picker line text type is an object a string that represents a versiona multi-line text.

    • Accessing a field of Single-Version picker Multi-line text field type:   You can access a custom field of SingleMulti-version picker 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<Version> String
      • Example:

        Release date

        Text of the

        selected version:

        field

        Code Block
        languagegroovy
        linenumberstrue
        issue.get("
        <Single
        Multi-
        Version
        line 
        picker
        text field 
        name>")?.last()?.getReleaseDate(
        name")


    • getAsString("

      <Your

      Your custom field

      name>

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

      name of the version

      text:

      • Example:

        Release date

        Text of the

        selected version:

        field

        Code Block
        languagegroovy
        linenumberstrue
        issue.getAsString("
        <Single
        Multi-
        Version
        line 
        picker
        text field 
        name>
        name")




    Panel
    borderStylesolid
    Multi-version picker

    Read-only text field type

    • Description: A field of MultiRead-version picker type is an array of objects. Each version is an object in itselfonly text type is a string that represents a read-only text.

    • Accessing a field of Multi-version picker line text field type:   You can access a custom field of MultiRead-version picker only 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<Version>

      Example: Are the selected versions same as the Affects Version/s?

      Code Block
      languagegroovy
      linenumberstrue
      issue.get("<Multi-Version picker field name>") == issue.get("versions")
      Example: Release date of the last versionsthe Issue interface:

    ...


    Date/Time picker

    Panel
    borderStylesolid
    Single-line text field type

    Date picker

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

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

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


    Panel
    borderStylesolid
    Multi-line text field type

    Date time picker

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

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

        Text of the field
        • return the date without the time value (or rather at 00:00:00)

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


      • getAsString("
      <Your name> text
      • date-time:
        • Example:

        Text of the field
        • Date time picker value

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

          To manipulate the date see here

    Others

    Panel
    borderStylesolid
    Read-only text

    Numeric field

    type

    ...



    Panel
    borderStylesolid
    Date

    Project picker type

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

    • Access

      Accessing a field of

      Date

      Project picker typeYou can access a custom field of

      Date

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


    Panel
    borderStylesolid
    Date time picker

    URL field type

    • Description: A field of Date time picker type is a Timestamp (Date) object. A field of URL type is a string representation of an URL

    • Accessing a field of Date time picker URL type:  You You can access a custom field of Date time Project picker type using any of the following getters of the Issue interface:

    ...


    Add-on provided custom fields

    Checklist for Jira

    Panel
    borderStylesolid
    Numeric field

    Checklist

    Project picker type

    • Description: A field of Project picker type is an object describing a project.

    • Accessing a field of Project picker typeYou 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>
        • Example: Value of the numeric field
          .first().name


        • Example: is a specific ChecklistItem selected?

          Code Block
          languagegroovy
          linenumberstrue
          issue.getAsString("<Numeric field name>")
    Panel
    borderStylesolid
        • 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
          }


        • 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 key of the project:with comma separated ChecklistItem

        • Example: Name of the project picked:All Checklist item

          Code Block
          languagegroovy
          linenumberstrue
          issue.getAsString("<ProjectChecklist picker type field name>name")


    Insight custom fields

    Panel
    borderStylesolid
    URL field type

    Insight Object/s

    • Description:   A recommended Insight field of URL type is a string representation of an URLthe type Insight Object/s that supports both single and multiple values.

    • Accessing a field of URL of Insight object/s type:You  You can access a custom field of Project picker type using of Insight 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 getAsStringYour custom field name") or get("customfield_xxxxx")that returns a String representing the URL Collection<ObjectBean>
        • Example: URL value Name of the first Insight object

          Code Block
          languagegroovy
          linenumberstrue
          issue.get("<URLcustom type field name>name")

    Add-on provided custom fields

    Checklist for Jira

        • ).first().name



    Panel
    borderStylesolid
    Checklist

    Insight Readonly Object/s

    • Description: A Field A field of the type Checklist, is an array of Check list items. Each selected ChecklistItem is an object in itselfInsight Readonly Object/s that displays Insight Object/s.

    • Accessing a field of

      Checklist type

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

      Checklist 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
      linenumberstrue
      issue.get("<Checklist field 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
      }

      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

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


    Panel
    borderStylesolid

    Insight Referenced Object (single)

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

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


    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: