Forums

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

Changing the assignee triggered with Issue Update event

Nimesh Perera
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!
June 22, 2018

When i change the assignee using assign tab it will trigger with "ISSUE_ASSIGNED_ID" event. And also when i click assign to me it also trigger with "ISSUE_ASSIGNED_ID" event.

But when i changed assignee using the searchable text field which is in people panel it will trigger with "ISSUE_UPDATED_ID". But I changed the assignee. How can I catch that action when I changed assignee using that searchable text field. 

I want to catch this event through my plugin.(Add-ons). 

Jira version - 7.10.0

1 answer

1 accepted

2 votes
Answer accepted
Gaston Valente
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.
June 22, 2018

Nimesh,

You can access the request data on a listener that captures ISSUE_UPDATED event, an then check if it contains a value for the field assignee to trigger the action or not.

miikhy
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.
June 22, 2018

Definitely agreed, taking both events and checking for data when ISSUE_UPDATED is triggered is the simplest in my opinion. Will allow you to catch it even when other fields are updated!

Cheers

Nimesh Perera
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!
June 23, 2018
Sorry. I could not get your idea. How can i access request data in following code. 

@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
Long eventTypeId = issueEvent.getEventTypeId();
Issue issue = issueEvent.getIssue();
if (eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {
MutableIssue issueObject = issueManager.getIssueObject(issue.getKey());
issueObject.setAssignee(ComponentAccessor.getUserManager().getUserByName("user3"));
issueManager.updateIssue(ComponentAccessor.getJiraAuthenticationContext().getUser(),
issueObject, EventDispatchOption.ISSUE_ASSIGNED, false);
log.info("Assignee : {}",issueObject.getAssigneeId());

} else if (eventTypeId.equals(EventType.ISSUE_RESOLVED_ID)) {
log.info("Issue {} has been resolved at {}.", issue.getKey(), issue.getResolutionDate());
} else if (eventTypeId.equals(EventType.ISSUE_CLOSED_ID)) {
log.info("Issue {} has been closed at {}.", issue.getKey(), issue.getUpdated());
}else if(eventTypeId.equals(EventType.ISSUE_ASSIGNED_ID)){
log.info("Uassigned {}",issue.getAssignee().getDisplayName());
}else if (eventTypeId.equals(EventType.ISSUE_UPDATED_ID)){
log.info("update assigned {}", issue.getAssignee().getDisplayName() );

}
miikhy
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.
June 24, 2018

Hi Nimesh,

There is a good example here: https://community.atlassian.com/t5/Answers-Developer-Questions/issue-updated-event-contents/qaq-p/548180

The changelog will show all updated fields, if assignee is part of them, you can deduce the issue have been re-assigned :)

Hope this helps!

Cheers

Suggest an answer

Log in or Sign up to answer