Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

109 views 0 7
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