Automatically assigning sub-tasks based on seed issues

Montana Fox June 14, 2022

I have a workflow which utilizes a custom field. This field has 60 options, each representing a unique dept in the company. The user selects all depts that will be stakeholders in the project. When they transition the issue, a scripted post-function iterates through the depts they selected, and creates a subtask for each one. Example: "Finance"

Meanwhile, I have another project which contains seed issues related to each of these depts, and a specific person assigned to each one. Example: "Finance" assignee = Bob Smith. "Maintenance" assignee = Melissa Brown.

When a stakeholder sub-task is created, it should look to the associated seed issue (using JQL), get the seed assignee, and make them the assignee for the new sub-task. Example: "Finance" dept is selected, so "Finance" sub-task is created. Upon creation, it finds the "Finance" seed issue, gets the assignee (Bob Smith), and sets them as the assignee for the new sub-task.

This way, I can make it so that assignees are handled automatically, based on dept, and they can be easily updated in the seed issues. If the assignee in the seed is changed, the next time a sub-task is created for that dept, the assignee will be the new person.

I have the post-function to update the assignee on the sub-task to match the assignee from the seed issue occurring during the sub-task's Create transition. The trouble I'm having is that it doesn't always work. Sometimes it does, but often the sub-task gets created but the assignee is not updated. I have tried changing the order of the post-functions. I have tried making it part of another separate transition, which is run after the Create transition has completed. I have tried using an event listener to trigger the separate transition. None of them work reliably. It works when I run that transition manually, but not when it's triggered automatically. My last resort will be to created an Escalation Service job which will run the transition on a schedule. I do NOT want to have to do it that way. I really want this to happen immediately, not on a delay.

Any advice? My guess is that the Create transition is not quite complete before it's running the Assignee update, so it's failing to process it. But I haven't found a reliable solution.

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2022

It sounds like you are doing almost everything right.  Specifically, "post-function on the sub-task create should set the assignee".  

I would actually not do it that way, it's the second-best option.  I would put the "look up who to assign" and set it as the sub-task is created (you are already running code that accepts the issue type and summary as the core things to create the sub-task with, why not throw in assignee there as well?)

To debug this, I think you need to look at patterns.  Are there patterns in the failures such as "Bob always gets assigned correctly, but Charlie never does" or "It fails when it gets run on Tuesday afternoons"?

Also, we don't know exactly what is failing.  There's two steps in this process, not one.  Do we know if it is failing to find the assignee to try to use, or if it's finding one and failing to put it into the issue?

Could you add logging to your code, just something simple that says "output an easily searchable string plus the name of the person I found to try to assign to"?  

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13.3
TAGS
AUG Leaders

Atlassian Community Events