Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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

Suggest an answer

Log in or Sign up to answer
0 votes
Ivan Tovbin
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.
Aug 11, 2018

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.

TAGS
AUG Leaders

Atlassian Community Events