I need help creating a listener in ScriptRunner to update a sub-task(s) Assignee to 'X' value if parent customField 'x' value updated to a certain option.
If Parent field 'Module' which is a select list changes to: UI
Then (Signoff) "which is a Subtask issue type" assignee should change to: 'Jane Doe'
Thanks a lot
Hi @Nour Durra , Just saw your request yesterday, worked on it and it was possible. It was a bit tough, so it was interesting. Hope this would help..!
Create a custom listener like shown in the image.
def issue = event.getIssue() as MutableIssue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_10488")
def cFieldValue = issue.getCustomFieldValue(cField)
case "Q1": userName = "kevin.e";break;
case "Q2 ": userName = "angelinjebapriya";break;
case "Q3": userName = "kevin.e";break;
case "Q4": userName = "angelinjebapriya";break;
case "Sales Team": userName = "kevin.e";break;
default: userName = null;
UserManager userManager = ComponentAccessor.getUserManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()
ApplicationUser assignToUser = userManager.getUserByName(userName)
// Get a list of the current issue's subtasks
def subtasks = issue.getSubTaskObjects()
// Loop through all the subtasks and delete them
def changeHolder = new DefaultIssueChangeHolder()
def i = it as MutableIssue
//update same custom field value in subtasks
cField.updateValue(null, it, new ModifiedValue(issue.getCustomFieldValue(cField), cFieldValue),changeHolder)
//set assignee as desired
issueManager.updateIssue(assignToUser, i, EventDispatchOption.DO_NOT_DISPATCH, false)
Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events