Forums

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

How to get last public comment date in JSM

Radhika Rajendran
September 18, 2024

I'm using an automation to capture last public comment date. If the latest comment is internal, it's ignoring previous external comments and returning empty. 

{{#issue.comments}}

{{#if(not(internal))}}

{{last.created.jiraDate}}

{{/}}{{/}}

There's a known bug in Jira. The inbuilt 'Last public comment date' custom field gives Last Internal Comment date if the latest comment is internal.

How to get the latest communication date with a customer?

2 answers

Suggest an answer

Log in or Sign up to answer
1 vote
Tuncay Senturk _Snapbytes_
Community Champion
September 20, 2024

First reversing the comments and then filtering out non-internal comments (not(internal)) will allow us to get the right order. If there is at least one comment, the first one will give us the correct comment.

{{issue.comments.reverse.filter(not(internal)).first.created.jiraDate}}
0 votes
Ludwig Einicke
May 8, 2026

Hi!

I just implemented something similar for JIRA/JSM cloud and can share my solution! I hope this answer still helps.:

 


1) Create a Field

Type: DateTime Picker

For our purpose we will say the Field name is "First Public Comment"

1.1) If necessary: Lock this field from user interaction

(only automation should be able to change values)

1.2) Make sure the field appears where you need it

- Contexts
- Field configuration / Field configuration Schemes
- Screens / Screen Schemes / Work type Screen Schemes

2) Automation setup:

2.1) Trigger

Set your trigger as needed

We will assume that you look at existing issues with potentially lots of Comments.

Small tangent: If the automation gets triggered by a new comment on an item, this gets trivial: Check if triggering comment is NOT internal, Check if field First Public Comment is empty. If both yes get triggering coment created as JiraDate and write to field First Public Comment.

2.2) Add Action: Create Variable

Name e.g. {{ExternalCommentDates}}

Smart Value: 

{{#issue.comments}}{{#if(not(internal))}}{{created.jiraDateTime}}~~~{{/}}{{/}}

2.3) Add Action: Create Variable

Name e.g. {{OldestExternalComment}}

Smart Value:

{{ExternalCommentDates.split("~~~").first()}}

2.4) Add Action: Add value to the audit log

(You DO use logging for easy debugging, right?)

Log message:

Dates: {{ExternalCommentDates}} | Oldest: {{OldestExternalComment}}

2.5) Add Action: Edit work item fields

Choose field to set: First Public Comment

Smartvalue: {{OldestExternalComment}}

 

3) Limitations

External Comments by Customers get counted in this version. For Comment-Triggered automation i would check the author for further details. Here it is more difficult but might not be needed.


Kind regards and best of luck!

 

EDIT: some mistakes

Ludwig Einicke
August 12, 2026

Okay wow, i just revisited this post and noticed that i solved the wrong problem. You want the last public comment.

Well, in this case there are two main questions:

1a.) Are you generating a report (looking at a bunch of Work Items at once and trying to find the "most recent visible comment date")

1b.) OR do you want this information filled into a field (e.g. Automation gets triggered by new comment and checks if that comment satisfys conditions to update the field)

2a.) Do you want any visible comment 

2b.) OR just visible comments towards the customer?

 

Case 1: 1a.)+2a.) basically works as abovementioned, just replace "first" with "last" and Adjust the Variable Name to "NewestExternalComment" The problem in your initial solution was just that

 {{last.created.jiraDate}}

does not work inside the list-iterative-function that you used. And getting the last (or first) Element after the conditional

{{#if(not(internal))}}

 requires the steps I explained above.

 

Case 2: 1b.+2a.) can be condensed quite a bit because if an automation gets triggered by the "new comment" event, a lot of information about the new comment gets handed over automatically. Meaning you can just use the Conditional Building Blocks from the Automation Builder to only continue after checking

if {{comment.internal}} is false

You just need one "Edit Work item Fields" Block afterwards, writing {{comment.created}} to your desired field.

Case 3 + Case 4: 1a.)+2b.) and 1b.)+2b.)

This needs one more step. Crucially you need something that identifies a "comment coming from your side". If you have a company domain and every colleague uses that for their logins, you can get the information via

 {{comment.author.emailAddress.substringAfter("@")}}

or, to strip away local mail endings

 {{comment.author.emailAddress.substringAfter("@").substringBefore(".")}}

In Case 3, you can use the following inside the iterative call (it DOES generate a bit of runtine though):

{{#issue.comments}}
{{#if(not(internal))}}
{{#if(author.emailAddress.substringAfter("@").substringBefore(".").equals("[yourdomain]"))}}

{{created.jiraDateTime}}~~~

{{/}}
{{/}}
{{/}}

 and split/evaluate it via the following steps similar to Case 1.

In Case 4, you would use an additional Conditional Block to check {{comment.author.emailAddress.substringAfter("@").substringBefore(".")}} while everyting else stays similar to Case 2.

 

Kind Regards,

Ludwig

TAGS
AUG Leaders

Atlassian Community Events