It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get the Issue status in IssueLinkCreatedEvent Listener Edited

I have a scenario when an Issue status is in specific status, I have to move from one status to other status by using IssueLinkCreatedEvent listener.

1 answer

1 accepted

0 votes
Answer accepted

I found way to find the Issue status in IssueLinkCreatedEvent.

Thank you!!


Here is sample Code:

import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult
import org.apache.log4j.Logger
import org.apache.log4j.Level

IssueManager im= ComponentAccessor.getIssueManager();
def event = event as IssueLinkCreatedEvent"Event Class:"+event.getClass());"DestinationObject: "+event.issueLink.destinationObject);"Issue Link :"+event.issueLink);

def destinationObject = event.issueLink.destinationObject

MutableIssue issue=im.getIssueByCurrentKey(destinationObject.key);"Issue Summary :"+issue.getSummary());"Issue Type :"+issue.getIssueType().getName());"Key :"+issue.getKey());

def status=issue.getStatus().getName();"status: "+status);
def actionId=141 //Status: Manager's Review  
def transitionValidationResult
def transitionResult
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

IssueService issueService = ComponentAccessor.getIssueService()

if(status == "Needs Review" && issue.getIssueType().getName()=="Thread")
transitionValidationResult = issueService.validateTransition(currentUser,, actionId,new IssueInputParametersImpl())

if (transitionValidationResult.isValid())
transitionResult = issueService.transition(currentUser, transitionValidationResult)

if (transitionResult.isValid())
{"Transitioned issue $issue through action $actionId")
{"Transition result is not valid") }
{"The transitionValidation is not valid")

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Align

Best Practices in Jira Align

Hello Jira Align customers! In order to better serve you on your journey with Jira Align, the Community team has worked with the Jira Align team to curate the content in this collection to better s...

58 views 0 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you