Automatically creating Subtasks from a Checkboxes field

Johannes Mayr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 25, 2023

I have a custom Field of type "Checkboxes". There I can select multiple Items from a list (predesigned steps that need to be done. E.g. Step1, Step2, Step3). When I add a new item to the checkbox, I would like to have an automation rule that automatically adds a Subtask for every selected step with the description "Conduct Step1".

I created an automation Rule that checks the custom Filed for values to be added.

With {{fieldChange.toString}} I get a String of all currently selected boxes. 

Now I have to problems:

* How to seperate this list and create multiple subtasks --> currently it creates one subtask with the whole list a s a string

* How to check that the subtask does not already exist and a duplicate is created

 

jira.PNG

1 answer

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 25, 2023

Hi @Johannes Mayr -- Welcome to the Atlassian Community!

You could use an Advanced Branch, over the selected values of your checkbox field, and add a subtask for each one.

Please look here to learn about using Advanced Branches: https://community.atlassian.com/t5/Automation-articles/Branching-over-smart-values-in-Jira-Automation/ba-p/1741935

Also note that this type of branch executes in parallel for performance reasons, and so there is no guarantee of the order your subtasks will be created.

 

Regarding your question about preventing duplicates...That is a bit more complicated.

You could use Lookup Issues to first gather the current subtasks.  And then inside of the branch, use a condition to confirm the subtask does not exist before creating it.  Or you could just check the {{triggerIssue.subtasks.summary}} values, as that is already loaded.

 

And so an outline of your rule could be...

  • trigger: your checkbox field value changes
  • condition: issue type is what you expect (I recommend adding this condition.)
  • advanced branch: on the values of your checkbox field
    • action: lookup issues with JQL of parent = {{triggerIssue.key}} and summary = your branch variable
    • advanced compare condition: only proceed if {{lookupIssues.size|0}} equals 0
    • action: create the subtask

Kind regards,
Bill

Johannes Mayr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 30, 2023

Hi Bill,

thanks for your reply. I currently try to implement a simplified version that does not yet check for dublicates, but I'm struggling with the advanced branching function.

As suggested by the "When: Value changes for" block I used {{fieldChange.toString}} to get a list of the changed values of the checkbox.

jira2.PNG

Then I assign Summary field with {{WorkProduct}} in the "Then: Create a new" block.

This works so far, but I do only get one new subtask that has the whole list of selected items in the summary. So the "loop" does not work and is only executed once.

How to manage that my list is correctly iterated in the list?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 30, 2023

The {{fieldChange.toString}} smart value will just be text, and not a list of values.

Your two options are to use the split() function on any commas or to specifically use one of these smart values:

{{addedFieldChange.valueIds}} or {{addedFieldChange.values}}

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--fieldChange--

The specifics will depend upon how you are trying to use those in the create issue action.

Drishti Maharaj
Contributor
October 28, 2024

Hi @Bill Sheboy  - apologies for asking on an old post but I cam across this and I think it may be applicable to what I am trying to do also, however I have been trying to play around with this but I cannot seem to get it right.

The issue is that the other sub-tasks are still getting created so there is probably an issue with the "Lookup issues" and "Compare values".

I tried JQL of parent = {{triggerIssue.key}} and summary = your branch variable but I got this error -
Custom Smart Value JQL Search: "(parent = INC-930 and summary = Department) AND (project in (10047))" - The operator '=' is not supported by the 'summary' field.

Screenshot 2024-10-28 095815.pngScreenshot 2024-10-28 095803.png

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 28, 2024

Hi @Drishti Maharaj 

As you note, this is an older thread, and so I recommend creating a new question and linking back to this one.  That will ensure the maximum number of people see it to offer suggestions.

Back to your question...

When using a variable like you show in the JQL, the smart value must be enclosed in the curly brackets, like this:

parent = {{triggerIssue.key}} AND summary ~ "{{Department}}"

 

Kind regards,
Bill

Like Drishti Maharaj likes this
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 28, 2024
Like Bill Sheboy likes this
Drishti Maharaj
Contributor
October 28, 2024

Thanks @Bill Sheboy your answer helped me out. Managed to get the automation working as it should now. 

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events