Forums

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

Jira Smart Automations - Comments

Paul Fox-Reeks
Contributor
February 8, 2024

I've tried to find others that have this issue, but I've had no luck. I have an automation that will email and slack out certain tasks to stakeholders when the status of a task changes. It includes the status, and the comments. But the comments aren't pressed nicely, and I want to try and format it better. I want to replace the following entries in comments:

  • * - <ul><il> tags
  • !xxx! - images removed completely
  • [smart-link] with <a> tags
  • [accountId] just remove as it doesn't make sense.

Below are a couple of the example comments that get sent out, that I'm trying to format better.

The HTML block I have at the moment, just uses the {{comment.body}} smart value


 {{#issue.comments.reverse}}
<div style="background-color: #f9f9f9; padding: 10px; border-radius: 4px; margin-top: 10px; display: flex; align-items: center;">
<img src="{{author.avatarUrls.32x32}}" alt="Avatar" style="padding: 10px; max-width: 32px; max-height: 32px; vertical-align: middle; margin-right: 10px;">
<div>
<p><strong>Comment by:</strong> {{author.displayName}} at: {{created.convertToTimeZone("America/Denver").format("EEE, MMM d h:mm a")}}</p>
<p>{{body}}</p>
</div>
</div>
<br>
{{/issue.comments.reverse}}

 

Screenshot 2024-02-08 at 12.21.18 PM.png Screenshot 2024-02-08 at 12.21.04 PM.png

 

1 answer

1 accepted

1 vote
Answer accepted
Paul Fox-Reeks
Contributor
February 8, 2024

I actually found out how to correctly do this, however took some time going down the depths of documentation to find it: https://support.atlassian.com/cloud-automation/docs/convert-wiki-markup-to-html-or-plain-text-in-jira-automation/

I updated the code to:

{{#issue.comments.reverse}}
<div style="background-color: #f9f9f9; padding: 10px; border-radius: 4px; margin-top: 10px; display: flex; align-items: center;">
<img src="{{author.avatarUrls.32x32}}" alt="Avatar" style="padding: 10px; max-width: 32px; max-height: 32px; vertical-align: middle; margin-right: 10px;" />
<div>
<p><strong>Comment by:</strong> {{author.displayName}} at: {{created.convertToTimeZone("America/Denver").format("EEE, MMM d h:mm a")}}</p>
{{body.html}}
</div>
</div>
<br />
{{/issue.comments.reverse}}

 

Which produced:

Screenshot 2024-02-08 at 12.42.14 PM.png  

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.
February 8, 2024

Hi @Paul Fox-Reeks 

Well done, solving your own question!  :^)

To save you some time...you may notice the user mentions in your comments show in the Slack messages as Jira account id values, and not with the users' display names.  There is no easy way to change those, since the GDPR changes went into effect.

Theoretically...one could add a bunch of replaceAll() function calls, chained together after the body smart value, one for each possible user in your Jira instance.  That obviously would not be easily maintained in a rule, and so I would not recommend it.

If it looks too "unsightly" for readers in Slack, those could all be replaced to the same template text with a single replaceAll() with a regular expression.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
atlassian, team '25 europe, atlassian event, barcelona 2025, jira, confluence, atlassian intelligence, rovo, ai-powered collaboration, developer tools, agile teams, digital transformation, teamwork solutions, atlassian conference, product announcements

🌆 Team '25 Europe registration is now open!

Join the largest European gathering of the Atlassian Community and reimagine what’s possible when great teams and transformative technology come together. Plus, grab your Super Fan ticket now and save over €1,000 on your pass before prices rise on 3 June.

Register now
AUG Leaders

Atlassian Community Events