Hi Community,
I want to display the comments history of an issue on JIRA Dashboard in JIRA Data center.
I am also thinking of other ways on how to display the comments on dashboard as per the below use-cases:
1) Whenever a user is mentioned in a comment, can we show that comment to the mentioned user on Dashboard?
2) How can we show "Last Comments" or "Most recent comments" of an issue on the Dashboard?
3) Is there a way, when selecting the issue on Dashboard, we can display the comments history section on the Dashboard?
Please suggest possible solutions via available gadgets, scriptrunner scripting, JMWE app or JIRA automation.
It will help me to learn all the possibilities to achieve the above requirement.
Thank you
you can achieve your base use case of listing issue comments with a few lines of HTML, CSS and JavaScript using Report Builder. I have prepared an example for you:
This can easily be included in a dashboard as well:
If you want to try it out, install Report Builder from the Marketplace and import the following JSON file as described in the documentation from step 4:
{
"category": "scriptedReport",
"tags": [],
"script": "// Get the selected issue key from the input field\r\nconst issueKey = SR.getValueByFieldName('issueKey');\r\n\r\nif (!issueKey) {\r\n SR.render({\r\n comments: [],\r\n issueKey: ''\r\n });\r\n return;\r\n}\r\n\r\n// Fetch the issue comments\r\nconst comments = await SR.jira.getCommentsByIssue(issueKey);\r\n\r\n// New array to store comment data\r\nvar commentData = [];\r\n\r\nvar amount = comments[0].comments.length;\r\n\r\nconsole.log(amount)\r\n\r\nfor (const [i, comment] of comments[0].comments.entries()) {\r\n \r\n const dateString = comments[0].comments[i].created;\r\n\r\n // Create a Date object from the string\r\n const date = new Date(dateString);\r\n \r\n // Options for formatting the date\r\n const options = {\r\n weekday: 'long',\r\n year: 'numeric',\r\n month: 'long',\r\n day: 'numeric',\r\n hour: '2-digit',\r\n minute: '2-digit',\r\n second: '2-digit'\r\n // timeZoneName: 'short'\r\n };\r\n \r\n // Format the date into a pretty string\r\n const formattedDate = date.toLocaleDateString('en-US', options);\r\n \r\n // Map comment data\r\n commentData[i] = {\r\n author: comments[0].comments[i].author.displayName,\r\n created: formattedDate,\r\n body: comments[0].comments[i].renderedBody\r\n };\r\n \r\n}\r\n\r\nif (!comments) {\r\n SR.render({\r\n comments: [],\r\n issueKey\r\n });\r\n return;\r\n}\r\n\r\n// Render the data in the template\r\nSR.render({\r\n commentData,\r\n issueKey,\r\n amount\r\n});\r\n",
"template": "<div class=\"comments-container\">\r\n <h2>There are {{amount}} comments for Issue \"{{issueKey}}\":</h2>\r\n <table>\r\n <tr>\r\n <th>Author</th>\r\n <th>Created</th>\r\n <th>Comment</th>\r\n </tr>\r\n {{#each commentData}}\r\n <tr>\r\n <td>{{this.author}}</td>\r\n <td>{{this.created}}</td>\r\n <td>{{{this.body}}}</td>\r\n </tr>\r\n {{/each}}\r\n </table>\r\n</div>\r\n\r\n<style>\r\n\r\n .comments-container {\r\n margin-top: 20px;\r\n }\r\n \r\n table {\r\n width: 100%;\r\n border-collapse: separate;\r\n border-spacing: 20px;\r\n }\r\n \r\n th {\r\n border-bottom: 1px solid #cfc9d2;\r\n padding: 15px 20px !important;\r\n font-size: 18px;\r\n text-align: left;\r\n }\r\n \r\n td {\r\n padding: 5px 20px !important;\r\n text-align: left;\r\n border-radius: 12px;\r\n }\r\n \r\n td:hover {\r\n transition: 0.2s ease-in-out;\r\n background-color: #f3f3f3;\r\n }\r\n\r\n</style>\r\n",
"name": "Comment List for Issue",
"fields": [
{
"type": "1",
"name": "issueKey",
"title": "Issue Key",
"optionsList": [],
"isMulti": false,
"order": 1,
"defaultValue": "",
"_id": "6695145b7a344a83a0278296"
}
],
"permissions": {
"view": [
{
"type": "private",
"value": "private"
}
],
"edit": [
{
"type": "private",
"value": "private"
}
]
},
"filterBy": []
}
Your other use cases are also interesting. They could be implemented as well with just a little bit more code. Let me know if I should build it for you, it would be my pleasure. :)
If you are having trouble with the JSON above, feel free to contact me directly or reach our support team here: https://actonic.atlassian.net/servicedesk/customer/portal/8
Thanks,
Andreas
If you need to display comments or any other specific field on Jira dashboard, you can check an Activities gadget from Issue History for Jira developed by my team. I think it's possible to display all 3 cases:
1) You'll need to create Jira filter with something like comment ~ "username", and then select this filter when configuring gadget;
2) You can sort by dates in desc/asc order to see the most recent or the oldest comments changes
3) The gadget provides a history of comments based on the selected filters.
Example of comments history using Activities gadget:
The app is available for Data Center and Cloud users. A free 30-day trial is available, so you can check if it is good to solve your cases.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
your best tool to help you create this is Adaptavist Scriptrunner -- most recent comment. Comment history can be extensive on an issue-- so it will be a potential heavy lift. you might want to filter out comments created through automation rules--and would have to know the actor in the rules.
NOTE every @mentioned user in a comment would get an email from Jira so why a dashboard?
A dashboard content is based gadget interpreting filter results so you can a dashboard that displays issue key and comment in the results --- use filter results but you cannot filter the comment in this view.
Comment typically use fuzzy logic and scripts only so far. Last comment and most recent comment are the same thing.
Also assuming your are using only software project because if it is a service desk the complexity increases because you have internal vs external (shared with customer) comments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.