Forums

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

Change assignee from issue to linked issue.

Max October 13, 2023

I'm trying to set up an automatic Assignee change in related tasks.
If Reporter is changed in a task, in some related tasks, I need to change Assignee to Reporter in the main task.
Is there an example of a trigger in Script runner that performs this functionality?

2 answers

1 accepted

0 votes
Answer accepted
Salzi
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.
October 13, 2023

Hi @Max ,
do a custom script listener in Scriptrunner for the event issue updated and then filter whether the reporter has changed.

With HAPI you can easily set the assignee. Here's an example:

def issue = Issues.getByKey('IS1-6')

def orgIssueReporter = issue.getReporter()

log.warn(orgIssueReporter)

def linkedIssues = issue.getOutwardLinks()

linkedIssues.each { it ->
def linkedIssue = it.destinationObject
linkedIssue.update{
setAssignee(orgIssueReporter)
}
}
Max October 17, 2023 edited

Thanks for the example.
I can't understand why I get an error in one case and an empty list of related tasks in the other case.

The script is like this:

def issue = event.getIssue()
def issueKey = issue.getKey()


//def issue = Issues.getByKey('JIRA166-163')
def issueSummary = issue.getSummary()
def orgIssueReporter = issue.getReporter()
def linkedIssues = issue.getOutwardLinks()

log.warn(issueSummary)
log.warn("Linked issue" + linkedIssues)


linkedIssues.each { it ->
    def linkedIssue = it.destinationObject
    log.warn("Linked issue 2" + linkedIssues)
    linkedIssue.update{
       setAssignee(orgIssueReporter)
    }
JIRA-163 issue.PNG JIRA-163.PNG JIRA-164 issue.PNG JIRA-164 trigger.PNG
Salzi
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.
October 17, 2023

Hi @Max ,

In one example, the user does not have permission to be an assignee in this project.
And on the other hand, you would have to add the InwardLinks to the linkedIssues (unfortunately there is no function in HAPI that gets all the links). You can simply add both lists together:

def linkedIssues = issue.getOutwardLinks() + issue.getInwardLinks()
Max November 1, 2023

Hi @Salzi, Thank you, for your help. It's working.

0 votes
Craig Nodwell
Community Champion
October 13, 2023

Hi @Max this can be done, but can you be a little more clear on the ask.  Why would a reporter change?  

Max October 13, 2023

This is how the process is structured. From one project, related tasks are automatically created in other projects. And Reporter is responsible for them. If a task is transferred to another employee, then all related tasks are also transferred to him.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence, loom, atlassian intelligence, ai notes, ai-powered meeting notes, atlassian community events, ace, confluence ai, loom ai integration, ai note-taking, atlassian ai features, team '25, atlassian live learning, confluence automation

Unlock AI-powered meeting notes: Join our live learning session! 📹

Did you catch the news at Team ‘25? With Loom, Confluence, Atlassian Intelligence, & even Jira 👀, you won’t have to worry about taking meeting notes again… unless you want to. Join us to explore the beta & discover a new way to boost meeting productivity.

Register today!
AUG Leaders

Atlassian Community Events