Hi,
In my jira server instance we are using the Scriptrunner addon based on this want to create a scripted custom field (Test transition count) that counts the how many times transition used in a workflow and transition ID is (101). Please help me with the script that counts the how many times transition used. Please guide me how to achieve this script.
Thanks in advance,
Siva.
Got you point.
Possible solution:
You have to create a number field and then add a post-function in that particular transition to increment the particular custom field, with this each time you do a transition the field will get updated by 1.
Add below script in post-function:
Script:
import com.atlassian.jira.issue.CustomFieldManagerimport com.atlassian.jira.issue.fields.CustomFieldimport com.atlassian.jira.issue.util.DefaultIssueChangeHolderimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.ModifiedValue;DefaultIssueChangeHolder changeHolder = new DefaultIssueChangeHolder();CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();CustomField cf = customFieldManager.getCustomFieldObject(customField_id);def currentValue = (Double)cf.getValue(issue) ?: 0def newValue = currentValue+1;cf.updateValue(null, issue, new ModifiedValue(currentValue,newValue), changeHolder);
Change customField_id to the field of the custom field.
Hey @siva
This should be already there by default in scriptrunner, check in "Browse" section search for
By logic one is moving to particular status when they transition an issue, hence you can use this.
So create a field with a name and choose the status, that should work !
Regards,
Vishwas
@Vishwas
Thanks for the reply, here in my case the status had the 3 incoming transitions. So here the issue is it counts the all 3 transitions moves i just need only one transition move count. I hope you understand my concern please guide me any alternate ways thanks for the help.
Thanks,
Hello @siva
I see that you are looking for a solution with ScriptRunner but let me recommend our ready-built solution that provides the best flexibility. Our team at OBSS built Timepiece - Time in Status for Jirafor this exact need. It is available for Jira Server, Cloud, and Data Center.
Time in Status mainly allows you to see how much time each issue spent on each status and on each assignee.
The app also has Status Count and Transition Count reports that show how many times each status and each transition was used. This is exactly what you want.
For all numeric report types, you can calculate averages and sums of those durations grouped by the issue fields you select. For example total in-progress time per customer (organization) or average resolution time per week, month, issuetype, request type, etc. The ability to group by parts of dates (year, month, week, day, hour) is particularly useful here since it allows you to compare different time periods or see the trend.
The app calculates its reports using already existing Jira issue histories so when you install the app, you don't need to add anything to your issue workflows and you can get reports on your past issues as well. It supports both Company Managed and Team Managed projects.
Time in Status reports can be accessed through its own reporting page, dashboard gadgets, and issue view screen tabs. All these options can provide both calculated data tables and charts.
And the app has a REST API so you can get the reports from Jira UI or via REST.
Using Time in Status you can:
Timepiece - Time in Status for Jira
EmreT
Thank you very much for the help the script works perfectly but it shows the count only for recent updated issues is there any chance to count older issues as well. Once again thank you very much for the help
Siva
Hmm, that's correct the method I have suggested works for recently transitioned tickets.
I only had this tried on my end, but there could be a way to create a scripted custom field to do that which currently I am unaware off.
I hope someone finds this post and suggest you !!
Also to add on this, since the field is created now as per logic it should count the transition as and when it is done like for ongoing tickets, maybe to search in history of issues for older issues you may have to write a script to check the history manager of the issue and then get the count in the field.
It looks like you're new here. Sign in or register to get started.