Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup automation to read parent key from email description when creating subtask in project

Juraj March 20, 2025

we have some automation that makes subtasks automatically from sent emails (from outlook). it works nice, subtasks are created in project, assigneees are set from description from email and also priority is set same way.

And now, we would like to extend this automation the way that from description string will be parent set in subtask. eg. email will contain string #PROJXY-123# and this subtask will set its parent to key PROJXY-123 (if exists).

is it possible ?

Juraj

1 answer

2 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 20, 2025

Hi @Juraj -- Welcome to the Atlassian Community!

Without seeing the specifics of your issue Description's format, this is might be possible by:

  • using text functions to extract the parent key
  • branching to the parent with JQL
  • testing if the issue type supports having subtasks with a condition
  • adding the subtask

However if the trigger issue is the already created subtask, you will need to experiment to learn if editing the parent will "move" the issue or if the REST API endpoint must be called from the rule to do so with the Send Web Request action.

Kind regards,
Bill

Juraj March 21, 2025

hi @Bill Sheboy  , thanks for your answer. but... I am very junior in automation and do not understand your proposals. I will describe my situation better. 

1. we prepare email with text in body "#juraj" and "#high" and send it to jira.development@....smthx... 

2. automation creates sub-task in project eg. "Development" and set assignee to Juraj... and set priority to HIGH

3. but automation is not able to assign parent (TASK) automatically

we would like to teach automation, that if there is ParentID inside body of email (description), than automation sets parent for the subtast accordingly (eg. text in body "#PROJXY-123#" means that subtask should be assigned to parent with such issue ID)

i believe it is possible , but wonder how and hope is not too much difficult

 

Snímka obrazovky 2025-03-21 124927.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.
March 21, 2025

Please post an image of your entire rule in a single image for context.  Thank you!

 

And something you describe puzzles me: normally Jira email handlers create an issue from the email.  Do you instead have a rule triggered on Issue Created which is attempting to modify the issue?

 

Back to the scope of your original question, let us assume your Description contains the issue key somewhere in the text in that format, such as: #PROJXY-123#

That could be extracted and saved in a created variable using this expression:

{{issue.description.replace("\n", " ").split(" ").match("#([A-Z][A-Z0-9]++\-\d++)#").distinct}}

That works by:

  • replacing any newlines in the Description with spaces
  • splitting the result to make the search easier
  • using match() with a regular expression to only return valid issue keys
    • Project keys must start with an uppercase letter, followed by one or more uppercase alphanumeric characters.
  • add distinct on the end to prevent any duplicate keys

 

Like Juraj likes this
Juraj March 22, 2025

hi Bill, thanks for your effort ! here is my automation in screens. I like your code, but do not know how to use variable in automation

pic1.pngpic2.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.
March 22, 2025

That expression may be used with the Create Variable action near the beginning of your rule: https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Create-variable

With that, the resulting smart value could be used as the parent key.  For example, if the name used in the variable action was varParentKey the parent could be set to {{varParentKey}}

You may want to add a condition to confirm a value was found.

Juraj March 22, 2025

that's helping me to understand the point, thanks Bill . what I miss in this is , how to set Parent with variable. Shall I use "Edit Issue Filed" select Parent ... or some other way ?

sorry for that, maybe its stupid question..pic3.png

Juraj March 22, 2025

I did it this waypic4.pngpic5.png

Juraj March 22, 2025

automation did not work. here is audited log:

pic6.png

Juraj March 22, 2025

oh yes, I found error. variable should be written with brackets... and now it works perfect!!! thanks Bill so muchpic7.png

Like Bill Sheboy likes this
Juraj March 22, 2025

Bill, one more question. to make it more easy for my coleaques, I want them just to send NICK for parent and lookup table will do rest (you opened my eyes for these possibilties)

how to regex expression like this eg.

#CKV#

this does not work:

{{issue.description.replace("\n", " ").split(" ").match("#([A-Z0-9]++\b)#").distinct}}

I used regex101: build, test, and debug regex

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 23, 2025

That value appears to be static text, and not variable like an issue key.

Do you mean the Description will contain #CKV# rather than the key and then that value will be used somehow to identify the correct issue?

Juraj March 24, 2025

hi Bill, yes exactly.

I already made lookup table for that purpose. user can use Nick of parent in email description to identify parent and lookup table will send final parent issue key.

I think that only matter is how to write regex correctly as I did some mistake in my formula: {{issue.description.replace("\n", " ").split(" ").match("#([A-Z0-9]++\b)#").distinct}}

nick names will be like:

#CKV1# or #DIMS2# .... starting with string and ending with numeric value

 

Juraj March 24, 2025

i thing this is well working: match("#([A-Z0-9]+\d)#").distinct

thanks Bill once more !

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events