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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Automatically assign the sub-task to the user in a user picker field.

I use scriptrunner to create a set of sub-tasks when the status of the parent issue is changed, and I would like to assign the sub-task to the user who is specified in a user-picker field in the parent issue.

Is there a way to do this? any suggestion would be helpful.

Let me know if the question is not clear.

Thank you in advance.

Jun 

1 answer

1 accepted

There are a few examples below the 'Additional issue actions', which led me to doing this:

import com.atlassian.jira.user.ApplicationUser

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == 'Single User Picker CF Name'}

if (cf && sourceIssue.getCustomFieldValue(cf)) {
issue.setAssignee(sourceIssue.getCustomFieldValue(cf) as ApplicationUser)
}

 

If you're creating those subtasks all within Groovy without using the 'Create a sub-task' postfunction then that would be pretty similar process except that you would do IssueInputParameters.setAssignee() before validation/creating, but that's probably not the case I assume.

Thank you so much for your help, I will test it out.

@Radek Dostál 

Thank you so much for your help again.

The script worked perfectly, it picks the value of the field from the current parent issue, which is exactly I wanted.

I wasn't sure what "If you're creating those subtasks all within Groovy without using the 'Create a sub-task' postfunction" means, creating the subtasks using the other way?

Thanks,

@teisyun I meant that I assumed you were using the 'Create a sub-task' postfunction which is out of box from ScriptRunner, and that one contains the 'Additinal issue actions' box, rather than creating the subtask in your own custom code or some other implementation. In any case glad that you've found it and that it worked :)

Like teisyun likes this

@Radek Dostál 

I see, thank you for your quick reply, and Yes, it worked for me!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.14
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,203 views 8 29
Join discussion

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