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")



Panel
borderStylesolid

Multi-level Cascading select

  • Description: A field of Multi-level Cascading select is an object that represents multiple levels of parent and child options

  • Accessing a field of Multi-level Cascading select type: You can access a custom field of 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 custom field name") or get("customfield_xxxxx") that returns an array of LazyLoadedOption
      • Example: 

        Code Block
        languagegroovy
        issue.get("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 with comma-separated values of multiple levels of the field.

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

        Code Block
        languagegroovy
        issue.getAsString("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 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

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:

...