Best way to create multiple sub-tasks, one for each value in a checkbox list

Looking for insight into the best way to solve this issue:

  • Have a checkboxes custom field with about 10 options
  • Whenever one of the checkboxes is selected, a sub-task should be created.
  • The assignee for each subtask could be different
  • When boxes are checked could vary, so I believe I need to use a listener rather than a post-function.  Would Live Fields be an option as well?
  • Would prefer the functionality be in a single script rather than multiple if possible.
  • Have both JJupin and Scriptrunner plugins available
  • I'm not a developer - I typically search until I find close enough examples that I can copy

I started setting this up using the ScriptRunner Create Subtask function, but looks like I'll need to create a listener function for each option, which is not ideal.  However this does appear to handle all my needs, other than I'm unsure how to code the condition to ensure it doesn't create new subtasks nor modify existing ones for values that were previously checked.  Currently the Scriptrunner condition is using the following:

'My value' in cfValues['My Multi List']*.value

Any assistance would be greatly appreciated!


1 answer

1 vote

You will need a listener but quite a complex one because there's quite a lot of things you need to think through.  It's definitely better to use a single one though, rather than one per option.

On events "issue updated" or "issue transition"

  • Check the content of the event for changes to your custom field (if none, then do nothing)
  • Look at the changes to the field value, and
    • For any selection that was not set and now is,
      • Check for a subtask existing already,
      • if none found, create
  • For any selection that was removed/unchecked
    • Not sure - possibly nothing, possibly close existing sub-tasks, possibly delete (although that would be something I'd strongly recommend not doing)

Thank you for the response Nic.  I'm not concerned with boxes that may later be unchecked, so the 3rd bullet point you list can be ignored.  For the other 2, what would be the best way to compare the original field values to the new?

I'd run JQL to read through the existing sub-tasks for the issue and compare them with what I might be creating - any close match found, don't create it. 

Last time I did this, there was a simple case - we were creating sub-tasks by component, so a simple "parent = current issue and component = <component we're thinking of creating for>" test applied.

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,494 views 15 20
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