Example scripts
To homepage
Jira

Updating a Field in an Epic will Automatically Update the same Field in all the Epic's Child Issues
App in script

ScriptRunner For Jira
by Adaptavist
Compatibility

Jira (8.22 - 9.3)

ScriptRunner For Jira (7.6.0)
Language |
groovy
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
def issue = event.issue as MutableIssue
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def projectGroup = customFieldManager.getCustomFieldObjectsByName('Project Group').first()
def epicLink = customFieldManager.getCustomFieldObjectsByName('Epic Link').first()
def projectGroupValue = issue.getCustomFieldValue(projectGroup)
def subTasks = [] as ArrayList<Issue>
if (issue.issueType.name == 'Epic' && issue) {
def links = issueLinkManager.getOutwardLinks(issue.id)
links.each {
def destinationIssue = it.destinationObject as MutableIssue
destinationIssue.setCustomFieldValue(projectGroup, projectGroupValue)
issueManager.updateIssue(loggedInUser, destinationIssue, EventDispatchOption.DO_NOT_DISPATCH, false)
subTasks = destinationIssue.subTaskObjects.collect { it }
}
} else if (issue.getCustomFieldValue(epicLink)) {
def links = issueLinkManager.getInwardLinks(issue.id)
links.each {
issue.setCustomFieldValue(projectGroup, it.sourceObject.getCustomFieldValue(projectGroup) )
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
} else if (issue.subTask) {
subTasks.addAll(issue)
}
subTasks.each {
def subTask = it as MutableIssue
subTask.setCustomFieldValue(projectGroup, it.parentObject.getCustomFieldValue(projectGroup))
issueManager.updateIssue(loggedInUser, subTask, EventDispatchOption.DO_NOT_DISPATCH, false)
}
Having an issue with this script?
Report it here