On transition to InProgress, subtasks of this issue should be assigned to 'xyz' user. How to do that?

Through groovy script  on an issue, how to write code to set assignees for the subtasks of the issue? I tried getting the subtask objects and iterating through each one of them and setting the assignee id, but i get the error that '"cannot set read-only property: AssigneeId". How should I go about this?

1 answer

1 accepted

0 vote
Vasiliy Zverev Community Champion Nov 24, 2016

Issue class is just represents issue. All methods to modify it are into MutableIssue. Issue.getSubTaskObjects() return collection of Issue objects. Since it is requered to transform it into MutableIssue ones. I usually do it like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue

MutableIssue mutableIssue;
IssueManager issueManager = ComponentAccessor.getIssueManager();

for(Issue subtask: issue.getSubTaskObjects()){
    mutableIssue = issueManager.getIssueObject(subtask.getId())
    mutableIssue.setAssigneeId("")
    //
}

@Vasiliy Zverev but this doesnt change the assignee id of the subtask issue. It just sets it for the mutable issue object we created. right?

Okay I just ran an updateissue() and it worked! Thanks a lot!!!!  laugh

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

93 views 0 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you