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:
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}}
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:
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 nowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.