Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Smart Value Logic for Excluding first Comment

Chris Riffey August 20, 2022

Hello wonderful, knowledgeable people. 

I have been asked by management to extend our customer comment notifications to include the history of all the comments for the ticket. 

The default notification covers the last comment just fine with:

*${event.user.name} commented:*

${comment}

 

Beyond this, I now want to include the rest of the comments in reverse order. That part is pretty easy. However, since the last comment is already included above, I wanted to avoid including that one a second time and just start with all the comments after the last one. After working with it for an hour, below is what I came up with but it doesn't work. Any ideas what I am doing wrong?

*Comment History:*

{{#issue.comments.reverse}}
{{#if(not(equals(issue.comments.last.body, body)))}}
*{{author.displayName}}* on *{{created.convertToTimeZone("America/Los_Angeles").jiraDate}}* at *{{created.convertToTimeZone("America/Los_Angeles").shortTime}}*
-----------------------------------------------------------
{{body}}

{{/}}
{{/issue.comments.reverse}}

 

2 answers

1 accepted

3 votes
Answer accepted
Chris Riffey August 22, 2022

Good news and bad new as it turns out. 

The good news is that I figured out how to do it with information from the section called "Combined function examples" on this page: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/

So the answer is basically this: 

*Comment History:*

{{#issue.comments.reverse}}
{{^first}}
*{{author.displayName}}* on *{{created.convertToTimeZone("America/Los_Angeles").jiraDate}}* at *{{created.convertToTimeZone("America/Los_Angeles").shortTime}}*
-----------------------------------------------------------
{{body}}

{{/}}
{{/}}

This would be great, but as it turns out, the customer notification system in Jira is REALLY terrible. You apparently can't use smart values despite the existence of "variables". So unless I want to try and recreate a customer notification (along with CSS styles and everything) in automation, which would still come from the automation email address, I guess I have to give up this dream of giving our customers useful context in their notifications. I found this suggestion that is worth voting on but even that probably won't fix it. https://jira.atlassian.com/browse/JSDCLOUD-4642

Situation is terrible. 

0 votes
Carlos Faddul
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 20, 2022

Hi @Chris Riffey , but this is a Customer Notifications right ?

The customer notifications are trigger basead on events.

Smart values it is not the best way to show all history of ticket comments.

Why don't you trigger an automation once a day, sending the email containing the entire comment history?

This way, it would decrease the amount of repeated notifications and history that the customer receives.

Chris Riffey August 20, 2022

Hey Carlos, thanks for the response. I don't see how this solution would reduce repeat notifications. It sounds like it would increase it by having the customer regularly receive emails even if nothing changes in the case. 

I want it to be trigger-based as it is now so they only get notified when something changes in the case (ex when an agent comments to them). What I am after is a way to give them more context on the comment they are getting at that time. The default notification only shows the most recent agent comment, not even what they are commenting on. So if the agent says something like "yes, we can do the second thing you suggested, just tell me when you are ready", it is not readily apparent what "the second thing" is to the customer. Especially, if the case has not had any activity in a few days or if they are dealing with multiple cases as many of our power customers do. 

I want to show the customer, along with the most recent comment, the comments that came before so they have the context all in one place. I already have that part working with the section contained within:

{{#issue.comments.reverse}}

{{/issue.comments.reverse}}

My only remaining issue is I want the most recent comment to be removed from that section because it is already being written at the top of message and it seems messy to have it written a second time below. I'd rather the first thing below is the second to last comment which would be the one the agent is likely responding to. Heck, even if I just had that one it would be helpful. 

I feel like there is probably a straightforward answer, I just don't know enough about all the ins and out of smart values. I am assuming my problem is the "equals" comparison I am doing and I don't know how to address the "this" comment (the one currently being iterated through in the #issue.comments.reverse section). Does anyone know? 

Suggest an answer

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

Atlassian Community Events