Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Update all Subtask Components Field Automatically if anyone Update the Parent Issue Component field

HARIOM MAKWANA
January 9, 2023

When I am Using Below Code and Update My Parent issue Components field my Subtask issue Components are not Updating.

----------------------------------------------------------------------------------------------------

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
// current issue
def issue = event.issue as MutableIssue
if (issue.getIssueType().getName() == "Sub-task") {
// the name of the field to check
final String fieldName = "Parent Issue"
// user that will make updates
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
// check if a right field was updated
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find
{it.field == "Sub-task"}
if (change) {
def issueManager = ComponentAccessor.getIssueManager()
// get components of parent issue
def components = issue.getParentObject().getComponents()
issue.setComponent(components)
issueManager.updateIssue(loggedInUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
} else return
} else return

1 answer

0 votes
Yuki Reid
Contributor
October 3, 2018

Actually, I figured out how to eliminate the Jql board filter by enhancing my 2nd script and using it as my board filter query.  However, would still like to know if there's a way to combine the two scripts.  Then there's only one thing to manage.  :D 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events