• Community
  • Products
  • Jira
  • Questions
  • In Post Function when I try to create a subtask on Issue Creation transition, the subtask inherits assignee from Parent

In Post Function when I try to create a subtask on Issue Creation transition, the subtask inherits assignee from Parent

I am trying to use Post Function in my workflow to to automatically create a subtask when an issue gets created. However, I'd like to set different assignees for both Parent task and Subtask, It appears that Post Function is forcing the assignee of the subtask to mimic that of the parent task. 

For a variety of reasons I am not using Component in my Issue Creation screen but rather use a Custom Field that mimics Component.

Here is what the sequence of Post Function and any custom script looks like. Below is the exact copy of what I see in my workflow Post Function. 

  1. The field Component/s will take the value from Custom Field. Source and destination issue are the same.
  2. Assign the issue to the lead developer.
  3. Creates the issue originally.
  4. The contents of the field Component/s will be purged.
  5. The contents of the field Assignee will be purged.
  6. Fire a Issue Created event that can be processed by the listeners.
  7. Script workflow function : Create a sub-task.
    Subtask will be created with issue type: Sub-task

Step 7 uses the following code:

issue.summary = (issue.summary)
issue.assigneeId = 'username@email.com'

It is worth noting that Step 7 on its own executes fine and assigns the subtask to the proper user. It is when I try to assign the parent task, that subtask will inherit assignee from the parent task. 

Any suggestion is welcome and appreciated!

4 answers

You can't do that in a listener, you need to do a proper edit if you want to change values after the transaction has already been committed. 

You should just a standard script post-function, place it towards the top of the list of post functions, and that should work. Although I don't know what line 1 is supposed to do.

Hi @Jamie Echlin [Adaptavist], any help/suggestions will be appreciated! cheers!

I am using a Custom Field to mimic Component but with a different name. Line 1 essentially copies the value from the custom field into the component. Component has a Lead associated with it. So when ticket gets assigned through Line 2, it will get assigned to the proper owner. 

I am having an issue getting the custom script post function executing. My systems set up tells me that ScriptRunner is enabled but for the life of me I cannot get the custom post function to do anything. 

Hi @Jamie Echlin [Adaptavist]

But in the documentation here https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Clonesanissueandlinks for cloning it is mentioned that and I quote:

"If you want to override some of the field values rather than have them inherited from the source issue you can specify that in the Additional Code field"

Is it not possible to override the subtask assignee in Additional Code field?

I appreciate your response.

Thanks

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,343 views 13 19
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you