Forums

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

Questions about processing information in {{#lists}} in JSM automation

David Audet October 14, 2025

Since the default notification options in JSM are very limited, I was looking into JSM automation to create custom email notifications to send to our clients using different triggers (like creating a ticket or adding a comment). Here is the part of the email that I need help with : 

{{#if(not(issue.comments.body.isEmpty()))}}
<span style="font-size: 20px;">Comments :</span>
{{#issue.comments}}
{{#if(not(internal))}}
{{author.displayName}} added a comment {{created.jqlDateTime()}}
{{body.replaceAll("(\[\^.*?\]\n)","[Attachment added]")}}
{{/}}
{{/}}
{{/}}
This lists the comments that are not internal, like this :
Comments :
A, David added a comment 2025-10-06 14:24
[Attachment added]
This is comment #1 with an attachment.

A, David added a comment 2025-10-09 16:25
This is comment #2 without an attachment.
There are two issues with it:
1. The comments are listed from oldest (at the top) to newest (at the bottom). Since this is sent as an email and emails are usualy sorted from newest to oldest, I was looking for a way to reverse the list and display it in that order instead. 
2. Instead of replacing the attachment name with [Attachment added] when an attachment is added, I would like it to include the name of the file and get something like this : "File.pdf was added to the ticket,". I tried using the "issue.attachments" list, but it doesn't know when an attachment is internal or not. I also tried matching {{issue.attachments.fileName}} with the comment's body but it looks like it is not possible to access other variables within a {{#list}}{{/}} statement.
For example, this : 
{{issue.attachments.get(0).fileName}}
{{#issue.comments}}
{{body}}
{{issue.attachments.get(0).fileName}}
{{/}}
Gave me this : 
file.pdf
Comment #1
Comment #2
Instead of this : 
file.pdf
Comment #1
file.pdf
Comment #2
file.pdf
Sorry for the long post and thank you for your time.

1 answer

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.
October 14, 2025

Hi @David Audet 

For your first question to reverse the comment ordering, rather than using the built-in smart value for comments, I believe the rule would need to call the REST API endpoint and pass the parameter to orderBy the ascending created date / time.  That may be called using the Send Web Request action.

The internal filtering would be adjusted to instead check if the attribute jsdPublic is true or false in the webresponse smart value.

 

For the second question, in the comment body, attachment names are in the markup, and may be parsed out using text functions.  When converted to text, those will look like this example comment text:

my internal comment with an attachment !myAttachedFilename.png|width=513,alt="myAttachedFilename"! my end of the comment

 

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events