Forums

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

Send a last comment from a Assignne as reminder email body

Tejas Patil
Contributor
October 7, 2024

Hi Team,

I am looking for an option to send the last comment by Assignee as a part of reminder email to reporter.

With {{issue.comments.last.body}} I can get the last comment but how can I get the last comment by assignee?

Thanks,

 

2 answers

1 accepted

1 vote
Answer accepted
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.
October 8, 2024

Hi @Tejas Patil 

This is possible to do within an automation rule, and requires some advanced techniques...

 

One would think smart value, list filtering would work for this scenario:

!! THIS DOES NOT WORK !!

{{#issue.comments}}{{#if(equals(author.displayName,issue.assignee.displayName))}}{{body}}{{/}}{{/}}

The reason it does not work is the other issue fields are not visible once inside of the iterator over the comments.  That is, the assignee cannot be used for the filtering.

 

A possible workaround is to expand the comments as delimited text into a variable; create another variable for a dynamic, regular expression; use the inline form of list iteration to find a match(); get the last comment in the list; and finally parse out the comment body.

These techniques may be used for many scenarios with such limitations, and an example rule could be:

  • trigger: some trigger which provides the issue
  • action: create variable, for the regular expression
    • name: varRegularExpression
    • smart value: 
({{issue.assignee.displayName}}:.*)
  • action: create variable, expanding all comments into a delimited list with their author.  There is a colon between the author name and comment body, and a double-tilde ~~ to separate the records.
    • name: varCommentList
    • smart value:
{{#issue.comments}}{{author.displayName}}:{{body}}~~{{/}}
  • some action that needs the last comment body added by the assignee:
{{varCommentList.split("~~").match(varRegularExpression).last.substringAfter(":")}}
  • This works by...
    • split the variable back into a list records
    • match with the regular expression to find any comments by the assignee
    • grab the last record returned from the results
    • extract the comment body as the substringAfter the colon delimiter

 

I strongly encourage creating such a rule in a test project, and pausing to learn how it works before using it in you own projects.

 

Kind regards,
Bill

Tejas Patil
Contributor
October 10, 2024

Hi @Bill Sheboy

Thank you very much for your detailed explanation, it took a while to process and amend it, but it is working as expected.

Regards,

Tejas

 

Like John Funk likes this
John Funk
Community Champion
October 11, 2024

Hi @Tejas Patil 

Can you post your final rule that is working for future readers? Thanks!

Tejas Patil
Contributor
October 13, 2024

@John Funk,

Here is the final rule:

 Screenshot_5.jpg

 

Currently posting it as comment and in future will route it via email if needed.

Thanks

Like # people like this
John Funk
Community Champion
October 13, 2024

Thanks for sharing!

1 vote
Duc Thang TRAN
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.
October 8, 2024

Hello, 

I think it is complicated (but not impossible) to retrieve this value via smart values with a list https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists  with conditional logic https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/

Or  a easier way, but it requires admin product access.
(Create a custom multi-line text field called "Last Comment Assignee").

Through automation, trigger an action when a comment is added, then compare:
{{issue.comments.last.author.displayName}} and {{issue.assignee.displayName}}.

This way, you can use the smart value of this new custom field for other purposes.

:)

 

Tejas Patil
Contributor
October 10, 2024

@Duc Thang TRAN 

Thanks for the idea about custom field, I didnt give a try as it involves product admin.

Regards,

Tejas

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events