Versions Compared

Key

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

...

This page provides Groovy script examples to interact with Asset asset custom fields and Jira issues within your Jira workflows. These scripts can be used in post functions to update Asset asset attributes based on Jira issue transitions.

Tip

You can directly use issue or originalIssue of the transition, or fetch an issue by key or ID with Issue Manager (like anotherIssue in examples). return statements are optional but it makes the script more readable.

On this page:

Table of Contents
minLevel1
maxLevel6
outlinefalse
styledefault
typelist
printabletrue

...

Get "Select List (single choice)" or  or "Radio Buttons" JIRA custom field value

...

You can directly use issue or originalIssue of the transition, or get another issue with IssueManager (like the example below).

Code Block
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
 
def anotherIssue = ComponentAccessor.getIssueManager().getIssueObject("AP-5");
 
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_11001")
def cFieldValue = anotherIssue.getCustomFieldValue(cField)

def cityNameList = new ArrayList<String>()
for(String cityName: cFieldValue){
    cityNameList.add(cityName)
}
return String.join(", ", cityNameList)

...

Expand
titleScript:
Code Block
return issue.getResolution() != null ? issue.getResolution().getName(): "Not resolved"

Example result: Done

Get resolution of an other another issue

Please note that getResolution may be null for unresolved issues. 

...

If you want to assign a date or dateTime asset attribute, the value must be in ISO time format (for example, 2018-11-06T10:24:37.513).

  • For Date-Time fields, second and rest of the value will be purged automatically. Result example: 2018-11-06T10:24.

  • For date fields, minute and rest of the value will be  purged automatically. Result example: 2018-11-06.

...

If you want to assign a date or dateTime asset attribute, the value must be in ISO time format (for example, 2018-11-06T10:24:37.513).

  • For Date-Time fields, second and rest of the value will be purged automatically. Result example: 2018-11-06T10:24.

  • For date fields, minute and the rest of the value will be  purged be purged automatically. Result example: 2018-11-06.

...

If you want to assign a date or dateTime asset attribute, the value must be in ISO time format (for example, 2018-11-06T10:24:37.513).

  • For Date-Time fields, second and the rest of the value will be purged automatically. Result example: 2018-11-06T10:24.

  • For date fields, minute and the rest of the value will be  purged be purged automatically. Result example: 2018-11-06.

...