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.
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}")
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ^
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry to hear that, best of luck figuring it out
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.