Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Choose assignee during creation of sub-task post function

I have a transition screen with a custom field (with type, User Picker (single user), I called it "Internal User"). I also have a post function for this transition that creates a sub-task. I would like the post function to set the assignee of the sub-task to the custom field value of "Internal User". 

Here is what I have so far:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def customfieldname = customFieldManager.getCustomFieldObjectByName("Internal User")
def valueofcustomfield = issue.getCustomFieldValue(customfieldname) as ApplicationUser

if(valueofcustomfield){
issue.setAssigneeId(valueofcustomfield.username.toString())
}


The new sub-task is being created, but it is unassigned every time.

I am using script runner version 5.4.12.

I am using JIRA version 7.10.2.

1 answer

Hi Edward,

The method you are calling to set the assignee (setAssigneeId) is expecting a user id as its parameter and you are giving it a username instead. I would suggest using the setAssignee method instead, like so:

issue.setAssignee(valueofcustomfield)

Also make sure that your post function (the one, that creates sub tasks) is placed last in the post functions list in your transition. That way you'll ensure that it's executed after your main issue has been updated with the value for your custom field and so the assignee of your sub task will be set correctly.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

141 views 1 2
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you