Forums

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

Jira Cloud scriptRunner post function how to set the assignee when creating subtask

Kelvin Fielding February 5, 2018

I want to automatically create sub-tasks which I've found a ScriptRunner post function to do this but I want to set the assignee the same as the parents,

I've not been able to find examples for Jira Cloud ScriptRunner.

4 answers

1 accepted

0 votes
Answer accepted
Kelvin Fielding February 8, 2018

This works:

 

if (issue.fields.assignee != null) {
logger.info("Setting assignee to ${issue.fields.assignee}")
subtask.fields.assignee = issue.fields.assignee
} else {
logger.warn("Parent issue does not have an assignee: ${issue.fields}")
}

Kimmy Roberts March 31, 2018

Thanks :)

0 votes
Eduard Diez
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.
January 23, 2019
0 votes
admin January 23, 2019

In cloud how will make?

Thank's

0 votes
Jackson Farnsworth
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.
February 5, 2018

If you already have a handle for the issue:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.type.EventDispatchOption

Issue subtaskIssue = //however you're getting the issue here

ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()

Issue parentIssue = subtaskIssue.getParentObject()
subtaskIssue.setAssignee(parentIssue.getAssigneeUser())

issueManager.updateIssue(user, subtaskIssue, EventDispatchOption.ISSUE_UPDATED, false)

 

Granted, I'm more familiar with Server JIRA, so this might not work. Good luck.

Kelvin Fielding February 6, 2018

Yes, the imports in Jira Cloud do not work, I get :-

 

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 2: unable to resolve class com.atlassian.jira.issue.Issue @ line 2, column 1. import com.atlassian.jira.issue.Issue ^

Jackson Farnsworth
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.
February 6, 2018

Sorry to hear that, best of luck figuring it out

Suggest an answer

Log in or Sign up to answer