create subtask on transition not using automatic assignee

With the following in the additional issue actions the subtask is just being assigned to me and not the default assignee for the component.

import com.atlassian.jira.ComponentManager

import com.atlassian.jira.issue.CustomFieldManager

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.issue.MutableIssue

import com.atlassian.jira.issue.fields.CustomField

import com.atlassian.crowd.embedded.api.User

import com.atlassian.jira.project.Project

import com.atlassian.jira.bc.project.component.ProjectComponent

MutableIssue issue = issue

//parent = issue.getParentObject()

ComponentManager componentManager = ComponentManager.getInstance()

CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()

//Get valuje of user picker custom field

CustomField customField = customFieldManager.getCustomFieldObjectByName("Name")

customFieldValue = issue.getCustomFieldValue(customField)

//set components

Project project = issue.getProjectObject()

ProjectComponent component = componentManager.getProjectComponentManager().findByComponentName(project.getId(), "Laptop Provisioning")


String prefix = customFieldValue

println customFieldValue

println prefix

issue.summary = prefix + ' - Provision Laptop'

1 answer

1 accepted

Is the parent assigned to you? It defaults to taking all values from the parent IIRC. If you want it to take the value of the first component lead you need to do that yourself.

Not tested but something like:

def components = issue.componentObjects
if (components) {
    issue.assigneeId = components.first().lead

Yes it is assigned to me. Would you be able to give me the code that I can use to set the assignee to the component lead?

That worked! Thanks Jamie!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

445 views 8 26
Read article

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