Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,359,878
Community Members
 
Community Events
168
Community Groups

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

andreas Rising Star Sep 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 Sep 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 Sep 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

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

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

Like Paul Benati likes this

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

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
Community showcase
Published in Apps & Integrations

Apps for Confluence you won't want to miss: RSVP for September's Appy Hours

Calling all collaborators and Confluence users! Our Appy Hours event on September 29th features 4 presenters demoing functionality to superpower Confluence. Don't miss learning about these apps i...

112 views 0 9
Read article

Atlassian Community Events