You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hi,
For a specific status within the workflow I need to count how many issues were previously moved to this status within the project on a single day. There is a custom field in which I would like to store this value for each item moved to the status that day. e.g. 2 issues are moved to Status X today, then the values shall be 1 and 2 respectively
My first idea is to add a post-function to the transition leading to that status. However, this is beyond my groovy programming capabilities. Anyone can help to write a fast and smooth script to do this? (I am using Jira 7.2 and ScriptRunner 5) Thanks in advance!
Hi All,
I was able to write the following script. This works well, however it is very slow e.g. with having 100 issues in bulk edit.
Can anyone help improving and making faster by removing the nested iterations?
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def dnr = customFieldManager.getCustomFieldObject("customfield_10809")
if (issue.getCustomFieldValue(dnr) == null)
{
def cal = Calendar.instance
def diff = Calendar.SUNDAY - cal.get(Calendar.DAY_OF_WEEK)
cal.add(Calendar.DAY_OF_WEEK, diff)
Date dd = cal.getTime()
def issueMgr = ComponentAccessor.getIssueManager()
long projectid = 10300
def issues = issueMgr.getIssueObjects(issueMgr.getIssueIdsForProject(projectid))
int transitions = 0
for(item in issues)
{
def changeHistories = ComponentAccessor.changeHistoryManager.getChangeHistoriesSince(item, dd)
for(changeHistory in changeHistories) {
for(changeItem in changeHistory.changeItems) {
if("status".equals(changeItem.field)) {
if("Package".equals(changeItem.newstring))
{
transitions += 1
}
}
}
}
}
issue.setCustomFieldValue(dnr,(transitions+1).toString())
}
Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.