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.