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

teisyun January 22, 2021

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

0 votes
Answer accepted
Radek Dostál
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.
January 23, 2021

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.

teisyun January 25, 2021

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

teisyun February 3, 2021

@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,

Radek Dostál
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.
February 3, 2021

@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
teisyun February 3, 2021

@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
AUG Leaders

Atlassian Community Events