Forums

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

Grabbing email from last comment and make that email the reporter

rpatrick August 27, 2025

I think I have an issue with my smart value. I want it to grab the email in the last comment of a newly created issue. I tried with both "" and no "" around the regex but the rule still errors. Am I going about this the wrong way or do I have an issue with this smart value? 

{{issue.comments.last.body.match("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$")}}

Thanks for the help! 

image.png

image.pngimage.png

2 answers

1 accepted

0 votes
Answer accepted
rpatrick August 27, 2025

Smart value should be: {{issue.comments.last.body.substringAfter("Email address: ")}}

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.
August 27, 2025

Hi @rpatrick 

I do not believe it is possible to add a comment when creating a work item.  It must be created first and then comments can be added.  Where were you able to create one and add comments at the same time?

Next, and assuming the comment is added later, you appear to be extracting zero-to-many email address values, and then using them in a branch.  This will potentially lead to timing and collision problems when there are multiple values.  What do you expect to happen?

Finally, I believe there is special markup used for an email address value in comments, and other rich text fields.  And so each address is present twice.  This can be confirmed by writing an example value to the audit log, and then mitigated by adding the distinct function after the match.

 

Kind regards,
Bill

rpatrick August 27, 2025

Hi Bill, 

The comment is added automatically upon creation because the ticket is triggered from the submission of a form - though I did just figure out that I could use a different string manipulator which seemed to do the trick for populating the custom User Picker field 'Hiring Manager' as seen in the rule screenshot. 

This was what worked: 

{{issue.comments.last.body.substringAfter("Email address: ")}}

Thanks for your response! 

Like Bill Sheboy likes this
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.
August 27, 2025

Thanks for that information, @rpatrick 

 

In that case, I recommend adding the Re-fetch Work Item Data action immediately after that trigger (and before any other steps) to prevent timing problems. 

The reason is behind the scenes, the create definitely happens before the comment is added, leading to a short delay.  Thus the rule could start before the comment is available to the rule.  And because this is timing-related, it will work (or not work) intermittently without the re-fetch.

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