Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,552,518
Community Members
 
Community Events
184
Community Groups

Get Assignee and Worklog by status

Hello,

I'm trying to get the assignee and worklog by status as well. 
i.e get the current assignee each time the status is changed and get the worklog if entered on the status change.

Is there a way to achieve this?

Code for getting change history and work logs:

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.history.ChangeItemBean

def customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.getOSGiComponentInstanceOfType(IssueManager.class)
// TEsting only
Issue issue = issueManager.getIssueByCurrentKey("ACB-614")
def worklogManager = ComponentAccessor.getWorklogManager()

def statusChange = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, 'status')
def items = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, 'assignee')
def worklogs = worklogManager.getByIssue(issue)


 Thank you.

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
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.
Feb 06, 2018

I guess you are doing the right way. You have issue history and worklogs. Now you have to implement your logic. You need to connect statuses, assignee and worklog create time.

Thanks Alexey, what if the assignee isn't changed? is it possible to get the values of the assignee at a particular time?

Alexey Matveev
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.
Feb 07, 2018

GetChangeItemsForField returns a list of ChangeItemBean which contain the created date field. You would need to calculate who was the assignee in a certain status. You need to get all status changes and all assignee changes and build a matrix in your code which will tell you who was an assignee in a certain status. You can build it basing on the created date.

Hi Alexey, Thanks for the suggestion.

Hi Alexey,

I'm using the below 2 queries to get the change history by assignee and status.

How can I compare the queries to get the Assignee by status? i.e pass the time created of status change to match the time in assignee.

Status:


SELECT changeitem.oldstring, changeitem.newstring, changegroup.author, changegroup.created, jiraissue.id, jiraissue.summary
FROM jira_app.changeitem
JOIN jira_app.changegroup ON jira_app.changeitem.groupid=jira_app.changegroup.id
JOIN jira_app.jiraissue on jira_app.jiraissue.id = jira_app.changegroup.Issueid
WHERE jira_app.changeitem.field='assignee';

 

Assignee


SELECT changeitem.oldstring, changeitem.newstring, changegroup.author, changegroup.created, jiraissue.id, jiraissue.summary
FROM jira_app.changeitem
JOIN jira_app.changegroup ON jira_app.changeitem.groupid=jira_app.changegroup.id
JOIN jira_app.jiraissue on jira_app.jiraissue.id = jira_app.changegroup.Issueid
WHERE jira_app.changeitem.field='assignee';

 

Thanks.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events