Forums

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

How to get the count of a value from a singular select list for an Issue

Nannette Mori
Contributor
February 16, 2023

I need to get a count  DRs was rejected. We track this using a customfield singularlist that when the user selects the Failed Verification Transition the customfield is automatically set to "rejected".  I need to get a count for each individual DR how many times the DR was rejected and a total count of how many of our DRs failed Verification.

Is there a way to count how many times an issue was in a specific transition.  When the DR is failed the "Failed Verification" transitions to "In Progress".  So the only way we can tell if the DR was rejected is by the customfield field that automatically updates to "rejected" if the transition "failed Verification" is selected

 

Is there a way I can get this info using Script Runner Scripted Fields?

 

2 answers

1 accepted

1 vote
Answer accepted
Mark Segall
Community Champion
February 16, 2023

Hi @Nannette Mori - There's two parts to this:

I'll defer to the community if you prefer scriptrunner, but here's how you can do it with native tools/Jira Automation

  1. Tracking on an individual issue
  2. Tracking total issues

Tracking on an individual issue

You could simply look at the history for the issue and see how many times the issue has transitioned to the Failed Verification status.  If you need something for reporting like a gadget on a dashboard to say, show all issues where they transitioned more than n times, you would need to do something like this:

  • Create a custom numeric field to capture a tally of how many times the issue transitions
  • Create an automation rule that will tally it:
    • TRIGGER: Issue Transitioned (to Failed Verification)
    • ACTION: Edit Issue (your custom numeric field)
      • {{#=}}{{issue.your custom numeric field}}+1{{/}}

From here, you'll be able to do whatever reporting you want to use against the new custom field.

Tracking total issues

You could use this JQL as the base for your dashboard gadgets which will bring in any issues that were ever in Failed Verification:

status changed to "Failed Verification"

 

Nannette Mori
Contributor
February 17, 2023

Thank You for this information I will try this, however I need to get an historical count on for all the DR Records. Setting up what you gave me will track the count for any DRs that fail verification but not historical data....correct? 

Mark Segall
Community Champion
February 17, 2023

Correct - You would need to script something to update historically.

0 votes
David A
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 16, 2023

Hi @Nannette Mori 

ne solution could be you have to create a number field and then add a post-function in that particular transition or Automation to increment the particular customfield (+1) but only works in new issues.

If you need this count in past issues, with scriptedfield you must review ChangeHistoryManager Class 

In this example, they obtain the time, you must change the code and obtain only number times.

https://library.adaptavist.com/entity/count-the-time-an-issue-was-in-a-particular-status

I hope this help!

Nannette Mori
Contributor
February 17, 2023

I did create a scripted field 

Below is my code

def theStatus = "Rejected"

def changeItems = ComponentAccessor.changeHistoryManager.getAllChangeItems(issue)

def changItemsCount = changeItems?.findAll().{it.field == 'DR Verivication Decision' && it.getTos().values().contains(theStatus)}.size()

return changeItemsCount.toInteger()

 

However this script seems to only report the data when there is a update to the record.  I need to get historical count for each of the existing DRs records on how many times the DR was rejected without having the DR Record modified.  How do I get that data.  Also I would prefer to get the transition instead of using the customfield I am using above.  I don't want to use state because when a DR is failed it transitions back to In progress and there are other transitions that transition back to In progress so to ensure I get an accurate I would need to get the transition = "Failed Verification

 

Is this possible to do?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.22.6
TAGS
AUG Leaders

Atlassian Community Events