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?
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}}
Hi!
I just implemented something similar for JIRA/JSM cloud and can share my solution! I hope this answer still helps.:
Type: DateTime Picker
For our purpose we will say the Field name is "First Public Comment"
(only automation should be able to change values)
- Contexts
- Field configuration / Field configuration Schemes
- Screens / Screen Schemes / Work type Screen Schemes
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.
Name e.g. {{ExternalCommentDates}}
Smart Value:
{{#issue.comments}}{{#if(not(internal))}}{{created.jiraDateTime}}~~~{{/}}{{/}}Name e.g. {{OldestExternalComment}}
Smart Value:
{{ExternalCommentDates.split("~~~").first()}}(You DO use logging for easy debugging, right?)
Log message:
Dates: {{ExternalCommentDates}} | Oldest: {{OldestExternalComment}}Choose field to set: First Public Comment
Smartvalue: {{OldestExternalComment}}
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.