Versions Compared

Key

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

This page explains how to access the value of Pre-defined custom fields using Groovy. You can access them using the getters of the Issue interface. 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

Approvals

...

Panel
borderStylesolid

Customer Request Type

  • Field name: Customer Request Type

  • Description: The Customer Request Type field represents an object describing the information about the Service Desk used to create the ticket.

  • Accessing the Customer request type fieldYou can access the Customers Request Type field using any of the following getters of the Issue interface:
  • get("Customer Request Type") or get("customfield_xxxxx") that returns VpOrigin
    • Example: Customer request type:

      Code Block
      issue.get("Customer Request Type")?.getRequestTypeKey()


  • getAsString("Customer Request Type") or getAsString("customfield_xxxxx") that returns a String representing the request type name:
    • Example: Customer request type:

      Code Block
      issue.getAsString("Customer Request Type")


To get the Customer Request Type name as displayed on the issue view, you can use the following snippet:

Code Block
languagegroovy
linenumberstrue
import com.atlassian.servicedesk.api.requesttype.RequestTypeService
def requestTypeService = getComponent(RequestTypeService)
def sourceIssueRequestTypeQuery = requestTypeService.newQueryBuilder().issue(issue.id).build()
def requestTypeEither = requestTypeService.getRequestTypes(currentUser, sourceIssueRequestTypeQuery)
if (requestTypeEither.isLeft()) {
        log.warn "${requestTypeEither.left().get()}"
        return false
    }
return requestTypeEither.right.results[0].name


...

Panel
borderStylesolid

Organizations

  • Field name: Organizations

  • Description: The Organizations field represents an array of Strings describing the Organizations the issue belongs to

  • Accessing the Organizations field: You can access the Organizations field using any of the following getters of the Issue interface:
  • get("Organizations") or get("customfield_xxxxx") that returns a Collection<Organization>
    • Example: Number of Organizations the issue belongs to:

      Code Block
      issue.get("Organizations")?.size()

      Names of the Organizations:

      Code Block
      issue.get("Organizations")?.join(",")


  • getAsString("Organizations") or getAsString("customfield_xxxxx") that returns a String with comma separated Organization ID's:

    • Example: Names of Organizations:

      Code Block
      issue.getAsString("Organizations")


...

Panel
borderStylesolid

Satisfaction

...

Panel
borderStylesolid
  • Field Name: Parent Link
  • Description: The Parent link field is an object representing the Initiative of the current Epic. It returns com.atlassian.rm.jpo.env.issues.SimpleIssueAttributes.

  • Accessing the Parent Link fieldYou can access the Parent Link field using getAsString("Parent Link") or getAsString("customfield_xxxxx") that returns a String representing the key of the Initiative the Epic belongs to.

    • Example: Fetch the issue object of the Initiative the Epic belongs to:

      Code Block
      languagegroovy
      linenumberstrue
      def initiativeKey = issue.getAsString("Parent Link");
      if (initiativeKey==null)
        return null;
      return com.atlassian.jira.component.ComponentAccessor.getIssueManager().getIssueObject(initiativeKey);


...