Forums

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

Automation: How to get number of comment on an issue?

Bhavin Acharya
Contributor
May 23, 2021

Hello,

I want to capture through Automation, how much comments an issue has? 

Is it possible to get a number as output for Advance Compare Condition in Jira Automation.

Thanks for help in advance.

Bhavin Acharya.

2 answers

1 accepted

6 votes
Answer accepted
Mohamed Adel
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.
May 23, 2021

Hi @Bhavin Acharya 

You can use {{issue.comments.size}} and for detailed reference please visit Smart values - lists

Ismael Jimoh
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.
May 23, 2021

The above should is the answer here.

Thanks @Mohamed Adel .

Like Mohamed Adel likes this
Bhavin Acharya
Contributor
May 23, 2021

Thanks @Mohamed Adel 

Like Mohamed Adel likes this
Ana Laura de Melo May 31, 2022

How did you create the automation? It worked?

Chris McCullough
Contributor
December 19, 2022

@Ana Laura de Melo not sure if you ever figured this out or not but all you'd need to do is create an Automation rule with the following Edit Issue component.

For me the field is named "NC" for Number of Comments and you're just setting the field value to {{issue.comments.size}}

You can run this on a schedule or you can run it whenever a comment is added/deleted to update the field value.

Number of Comments.PNG

0 votes
Mattice Dossche November 27, 2023

Hi,

 

Can anyone explain how to run the automation rule above?

If possible step by step please.

 

I want to count the total of all comments in a certain Service Management project.

Is this not possible through the 'Reports' via Jira?

 

Thanks for your help!

 

Kind regards,

Mattice Dossche

Chris McCullough
Contributor
November 27, 2023

@Mattice Dossche I don't believe Jira allows you to do math expressions within the Filters so I am currently using a free app called "Sum Up Reports" to actually do the math for that sort of thing. You could also export all of the issues to an Excel file and then sum the total value from the field counting the number of comments on each issue.

For example what you want to do to start (assuming you haven't done anything yet):

  1. Create a new Custom Field for numeric values
    1. Mine is called "NC" for "Number of Comments"
  2. In the project that you want to count all of the comments - create a new Automation rule
  3. (Temporary) Add a scheduled trigger with a JQL filter for the project key
  4. Add an action to Edit Issue Fields
  5. Select the custom field you created before as the field to edit
  6. Set the value of the field to: {{issue.comments.size}}
  7. Publish the rule and run it
    1. Note that you may need to run the rule multiple times and/or with different JQL to capture all issues if it's a large project since the automation rules will timeout after a certain amount of time. So in larger projects this may take a while.
  8. Once all existing issues have been edited to count their total number of comments change the trigger on the rule to use the "Issue Commented" trigger and have it run for "All Comments". Then save and publish the rule so it runs every time there's a new comment on any issue in that project.
    1. At this point you shouldn't ever need to manually run the rule and it will just work quietly in the background
  9. Go to the Advanced Seach page and filter for the project using the new rule/custom field. You may need to do a JQL search for the project key to get all issues in the project.
  10. In the top-right corner, click on Export and then "Export Excel CSV (All Fields)"
    1. Depending on the project size this could be a huge file. My particular project has about 2,000 issues and the .csv file here was about 12 MB
  11. Open the exported file in Excel and find the column with your custom field.
  12. Select the column to highlight everything and look at the "Sum" value in the lower-right corner of Excel
Anil Singh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 23, 2024

Hi,

 

Thanks for this I've managed to setup the rule for new tickets but I'm stuck on this step for old tickets. Can you add a screenshot of your example please.

  1. (Temporary) Add a scheduled trigger with a JQL filter for the project key

Thanks

Anil.

Suggest an answer

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

Atlassian Community Events