Change Epic Status Field When Resolution Gets Set

Overview

Epic issues in Jira Cloud have an 'Epic Status' field associated. Only the epics with an 'Epic Status' value different from 'Done' are visible in the epic panel of scrum boards. Use this script to synchronise the value of the 'Epic Status' field with the resolution of the epic, so it gets set automatically once the epic resolution transitions.

Example

Epic issues in Jira Cloud have an 'Epic Status' field associated. Only the epics with an 'Epic Status' value different from 'Done' are visible in the epic panel of scrum boards. Use this script to synchronise the value of the 'Epic Status' field with the resolution of the epic, so it gets set automatically once the epic resolution transitions.

Good to Know

  • Set the script as a listener for the "Issue Updated" event.
  • Add a condition to the listener so the script gets executed only for epic issues.

Requirements

Jira Jira

    
// Add the next line as a condition to the script listener, so it gets executed only for epic issues, the line must be written uncommented: // issue.isEpic // Check if the resolution has been changed def resolutionChange = changelog.items.find { it.field == 'resolution' } logger.info("The resolution change of issue '${issue.key}': ${resolutionChange}.") if (!resolutionChange) { logger.info("The resolution didn't change.") return } // Compute the 'Epic Status' value to set based on the resolution value def newEpicStatusValue = (resolutionChange.toString == 'Done') ? 'Done' : 'To Do' // Get the 'Epic Status' field ID final epicStatusFieldId = get("/rest/api/2/field") .asObject(List) .body .find { (it as Map).name == 'Epic Status' }.id logger.info("Updating Epic Status field (${epicStatusFieldId}) to '${newEpicStatusValue}'.") // Update the 'Epic Status' field value put("/rest/api/2/issue/${issue.key}") .queryString("overrideScreenSecurity", Boolean.TRUE) .header("Content-Type", "application/json") .body([ fields: [ (epicStatusFieldId): [value: newEpicStatusValue] ] ]) .asString()
Discovered an issue? Report it here

Suggested for you