I have seen various solutions proposed for things similar to what I want to do, but not exactly. I want to create a transition that spawns a subtask, and have the Assignee for the subtask be something chosen in a transition screen.
The closes solution I've seen is Create Sub-task on Transition plugin, but there the choices for Assignee for the sub-task are Current User, Parent reporter, Parent assignee, Project Lead or Specific User. I am fine to have a custom user field that this plugin can grabe the user from, but that's not an option.
How do I get the subtask to have an assignee chosen in the transition that doesn't force me to make the parent have the same assignee?
I am an idiot. The subtask I was creating used the same workflow as the parent, and for the New step in that workflow, I had restricted who was assignable to only the project lead. Thus, when I went to assign to a developer, it failed. No error message of course, but that's jira for you...unless it's one of their super-cryptic 138 entry long stack traces with no groovy script identifier. Worse than useless.
Alas, the answer is: don't be an idiot like me.
Did my solution work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Neil! Do you know how assign subtask without visualisation?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Olga,
If you're talking about assigning the subtask when it's created as part of the Post Function, Here's what I did:
I set up a transition screen in the parent for the outgoing transition of the workflow step which has the assignee field in it. But, on the transition INTO that workflow step, I save the parent's assignee in a hidden field. Then, on the outgoing transition screen when the user chooses the assignee it will be given to the parent and subtask. Then, as a second Post Function in the same transition and after the Create Sub-task call, I call a groovy script that sets the Assignee (I'm still in the parent in that transition), back to the hidden field's saved assignee value.
Does that answer your question?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you remember to update the search index after creating the subtask?
# Once all the subtasks have been created # Update search indexes ImportUtils.setIndexIssues(True); ComponentManager.getInstance().getIndexManager().reIndex(subTask ImportUtils.setIndexIssues(False)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I decided to try using the groovy script post function to Create a Sub-task and add some scripting to the "Additional Issue Actions" section.
I'm printing debug info to the log, and even though I've now got the user from the custom user picker field I provide in the transition, I try to assign its value to issue.assignee and though in the script it appears to do it (based on debug log info), when the subtask is created it has the parent's assignee.
Here's the code:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "Assign To" ); log.error("Assign To is \"" + issue.getCustomFieldValue(customField_name) + "\"") issue.assignee = issue.getCustomFieldValue(customField_name) log.error("issue assignee is \"" + issue.assignee + "\"")
I've tried moving it up and down the Post Function list in case it had to do with when the issue was created, but with no effect. Ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have the transition spawn a custom screen that contains a custom field of type User Picker. Let's call the field "Sub-assignee". On transition, have the ScriptRunner plugin call a script that will create the subtask and assign it to the user referenced in the parent's Sub-assignee field. There's an example of a script that creates subtasks here. You should be able to mod it for your needs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I decided to try using the groovy script post function to Create a Sub-task and add some scripting to the "Additional Issue Actions" section.
I'm printing debug info to the log, and even though I've now got the user from the custom user picker field I provide in the transition, I try to assign its value to issue.assignee and though in the script it appears to do it (based on debug log info), when the subtask is created it has the parent's assignee.
Here's the code:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.IssueManager; import com.atlassian.jira.issue.Issue; import com.atlassian.jira.issue.MutableIssue; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "Assign To" ); log.error("Assign To is \"" + issue.getCustomFieldValue(customField_name) + "\"") issue.assignee = issue.getCustomFieldValue(customField_name) log.error("issue assignee is \"" + issue.assignee + "\"")
I've tried moving it up and down the Post Function list in case it had to do with when the issue was created, but with no effect. Ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
p.s., I've tried calls to setAssignee(issue.getCustomFieldValue(customField_name)
) setAssigneeId(issue.getCustomFieldValue(customField_name)
) and also tried those calls with just the username hardcoded in quotes. No luck.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suspect that the problem is that issue points to the parent issue, not the new subtask. That's why addSubTask() has its own call to issueObject = issueFactory.getIssue(). The issue() object contains the parent issue. The issueObject() object contains the subtask issue.
Another problem may be the Jira version. The above code is written for Jira 4.4. There were changes to the Jira API and specificially to com.atlassian.jira.issue.IssueFactory between v4.4.3 and v6.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both your points make sense, but I don't think that's what's happening. When I change the issue.summary text, it changes for the subtask. I think that the groovyrunner plugin runs all the groovy code I'm putting in the "Additional Issue Actions" field against the subtask. As I've been reading about the plugin, apparently all the fields from the parent are copied to the subtask, so when I get the "Assign To" custom field I created and filled out in the transition, I get it from the subtask and assign it to the subtask's assignee field. Even when I debug and dump the issue.assignee, it's got the correct new assignee, but it doesn't "stick."
What I think is happening is that I'm not updating the issue after I set the assignee to its new value. I'm somewhat new to groovy, and so just don't know how to do that. My latest attempt is from something I pinched out of a forum, but it's not quite working either, and I'm currently debugging why. Here it is:
def userManager = ComponentAccessor.getUserManager() def user = userManager.getUserObject('subtaskassigneeuser') issue.setAssignee(user) //Update the issue ComponentManager.getInstance().getIssueManager().updateIssue(ComponentManager.getInstance().jiraAuthenticationContext?.user, issue, EventDispatchOption.DO_NOT_DISPATCH, false) ComponentManager.getInstance().getIndexManager().reIndex(issue);
So, not sure why that doesn't work, but it doesn't yet...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What's even stranger is that in a simple transition in some other workflow, I use the exact same code in a groovy script (using the username in the form of a string in the issue.setAssigneeId() call) and it works. It only seems not to work in the "Additional Issue Actions" of the Create Sub-task script post function for the groovy runner plugin.
The string itself is retrieved correctly, and if I log the assignee after I call setAssigneeId it shows the new assignee, but after execution, when I look at the subtask, the assignee is that of the parent again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.