Create subtask(s) while adding a comment in a task

Sharon Freij March 3, 2022

I would like to create automatic (with a tag for example) a sub-task when i'm adding a comment in a task. 

Sometimes I want to inform people with a comment about current stats and combining this with creating new sub-tasks to solve the issue.

is this possible?

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.
March 3, 2022

Hi @Sharon Freij 

First thing, I am not using the Jira Core Server version...and...

My understanding is that Jira Core Server can use Automation for Jira (if it is installed).  Using an automation rule triggered on Issue Commented you could check for a person mention and then add the subtask assigned to them.

Please check with your Jira Admin if you have automation installed, and if so take a look at these sources/examples to get you started:

Kind regards,
Bill

Sharon Freij March 4, 2022

Hi @Bill Sheboy  , thank you for the quick reply. 

I've tried several options and still have some open questions, hopefully someone can help me with it ! 

So situation is:

1. During weekly meeting we create notes in Jira comments. Sometimes we have tasks to follow up, but this is stored in a comment. Sometimes with sometimes without user mention.

2. If user mention is available, I would like to create a NEW sub-task based on the content of the comment.

3. I'm able to do that, but only with a general summary for the sub-task. I did copy the content of the last comment in the parent, but it's assigned to no-one. 

 

I have 2 questions:

1. Can i create multipe subtasks based on 1 comment? For example the comment consists of:
#usermention Sharon has to check possibility delivery time.
#usermention Bill has to confirm the dimensions 
Now I, ofcourse, would like to have 2 different sub-task with 2 different summary's.

2. Then ... ofcourse I would like to have the sub-task assigne the same as the #usermention. 

Any ideas? It seems complicated, I was just curious if we can do something in automation with it.
If you do know the answer on how to add the assignee the same as #usermention in the comment on parent level, I would like to hear it :).

 

regards and thanks for your help,

Sharon

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.
March 4, 2022

Hi, Sharon.

Yes, you can do those things...using the string functions to help...and you need to use a consistent pattern in your comments.

Let's say your comment has a line for each task, with at most one mention per line (anywhere in the line).  Then this example rule would do it...details described below:

comment mentions to subtasks.png

 

  • trigger: issue commented
  • advanced branch: to split the comment into lines of text
    • smart value: {{issue.comment.last.body.split("\n")}}
    • variable name: varBodyLine
  • action: create a variable for the mentioned user's account id
    • variable name: varAccountId
    • smart value: {{varBodyLine.match("\[~accountid:(.*)\].*")}}
  • action: create a variable for the task, removing the account id
    • variable name: varTheTask
    • smart value: {{varBodyLine.replaceAll("(\[~accountid:.*\])","")}}
  • advanced compare condition: check if someone was mentioned in the line
    • first value: {{varAccountId}}
    • condition: does not equal
    • second value: leave this as empty
  • action: create a subtask
    • set the summary to {{varTheTask}}
    • set the assignee to {{varAccountId}}
    • You will need to type in those smart values, and then select them when they appear below the field.

 

Please modify this as you need, and let me know if it helps.  Thanks!

 

Kind regards,
Bill

Sharon Freij March 5, 2022

Hi @Bill Sheboy 

Wow, thanks for your answer. I fully understand, but still facing some issues in my own Jira environment.. :(

2022-03-05_11h23_42.png

Well, I'm not able to find the 'Advanced Branch' --> 'for each smart value'. I can only find 'JQL'. 
Something to do with the Jira version I have?

2022-03-05_11h24_48.png

 

Last but not least, 'then create variable' is also something which is not possible. 
Think that it depends on permissions or Jira version. Unfortunately don't have the same as you, so think it will not work.

besides that, many thanks for your help!

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.
March 5, 2022

Sharon, my apologies that I forgot that Advanced Branching and Create Variable are not yet supported for Jira Server versions. 

Please watch this thread to see any updates on advanced branching: Jira Automation - Advanced Branching over smart values (atlassian.com)

I believe there is a suggestion for adding Created Variables to Jira Server/Data Center, but I am unable to find it.

 

Those gaps mean you may only add one subtask at a time per comment, and you will need to inline all of the information extractions.  For example:

  • trigger: issue commented
  • condition: status is not "done" or the name of your completed status.  This prevents adding subtasks for completed items.  :^)
  • advanced compare condition to check if someone was mentioned
    • first value: {{issue.comment.last.body.match(".*\[~accountid:(.*)\].*")}}
    • condition: does not equal
    • second value: leave this as empty
  • action: create subtask, setting the fields
    • summary: {{issue.comment.last.body.replaceAll("(\[~accountid:.*\])","")}}
    • assignee: {{issue.comment.last.body.match(".*\[~accountid:(.*)\].*")}}

 

Please try that to see how it helps.  Thanks!

Suggest an answer

Log in or Sign up to answer