Can I check if a certain sub-task exists yet using Automation for JIRA?

andreas
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.
September 20, 2016

I want to write an Automation rule that only adds sub-tasks if that sub-task doesn't exist yet on an issue.  Is this possible with Automation for JIRA?

1 answer

1 accepted

1 vote
Answer accepted
andreas
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.
September 20, 2016

Once again the compare condition (see all our rule components) can help here with smart-values:

Project automation - Code Barrel JIRA 2016-09-21 10-16-13.png

So this rule uses the compare condition to create a string out of all existing subtask summaries. If no subtasks exist yet, then it will simply be the empty string. However otherwise it will concatenate all existing subtask summaries separated by a space character.  We then check using a regular expression if this string contains the subtask summary of the new subtask we want to create yet ("my awesome subtask") in this case.

Only if the existing subtask summaries don't match this string yet (i.e. it doesn't exist), will the rule continue and create our 1 sub-task with the summary "my awesome subtask".

The extra space inside this smart-value completion is important (it separates the subtask summaries by a space if there's multiple subtasks):

{{#issue.fields.subtasks}}{{fields.summary}} {{/issue.fields.subtasks}}
andreas
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.
September 20, 2016

You can also compare other sub-task attributes, by using something other than fields.summary in the example above. For example: fields.priority.name

Like Liam Harley likes this
isaacgarcia0829 December 4, 2018

How can I check if an issue already exists in an epic?

isaacgarcia0829 December 4, 2018

This works if the trigger issue is not an epic and has an epic link.existsInEpic.PNG

Like Paul Benati likes this
Paul Benati January 22, 2020

Thanks for this answer as it worked like a champ for my use case!

Liam Harley June 15, 2021

Hi I am new to Jira automation and this forum.  So please forgive me.

re 

{{#issue.fields.subtasks}}{{fields.summary}} {{/issue.fields.subtasks}}

 

 Can you show how you have used this in an example please.   My first delve into adding Automation to our Jira is to have approval and estimation tickets created.    I am using the transition to review as trigger.   I wan to ensure that if the status is reset, that the tasks are not created again.    

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events