Forums

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

How to update subtask priority based on parent'a priority update?

jgutierrez
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 17, 2020

This is NOT when creating an issue. This is for editing. 

 

Let's say after a week after the issue was created. The parent issue's priority is changed from high to critical. Is it possible for an automation rule to update the subtask priority? 

1 answer

0 votes
Bhanu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 17, 2020

You can build a script listener with the following code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
if(!event.issue.getSubTaskObjects()){
return
}

def customFieldManager = ComponentAccessor.customFieldManager

if(event.issue.getSubTaskObjects()){

def subtasks = event.issue.getSubTaskObjects()
def parentField = customFieldManager.getCustomFieldObjectByName("Your Parent Field's Name").getValue(event.issue)

subtasks.each {

def subtaskField = customFieldManager.getCustomFieldObjectByName("Your Subtask Field's Name")

def changeHolder = new DefaultIssueChangeHolder()

subtaskField.updateValue(null, it, new ModifiedValue(subtaskField.getValue(it), parentField), changeHolder) }}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events