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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Transition an issue with Scriptrunner Listener partially working

Hi,

I'm currently working in a sciptrunner Listener and what I'm attempting to achieve is that I have two different projects and once a ticket on Project "A" reach to "In Progress" status, Listener will catch the Generic Event and will transition an Issue on Project "B".

So far I'm testing transitions on one project only and I'm able to successfuly do the transition, but on the problem is that on the ticket I'm still seing the name of previous status, so transition are success but the name it's being stuck from previous status.

Now the odd part is that if I execute the same code on Scriptrunner console, transition are success too and the status name it's the current one not the previous as it happens with the Listener.

Below it's my Listener code, the only difference I do when I execute it on the console it's when I get the issue objet, so instead of issueMgr.getIssueObject(event.issue.key)
I use issueMgr.getIssueObject("KEY-123"):

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParametersImpl

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def cfMgr = ComponentAccessor.getCustomFieldManager()
def envCf = cfMgr.getCustomFieldObject('customfield_12412')

def issueMgr = ComponentAccessor.getIssueManager()
def issue = issueMgr.getIssueObject(event.issue.key)
IssueService issueService = ComponentAccessor.getIssueService()

def actionId = 281 // change this to the step that you want the issues to be transitioned to
def transitionValidationResult
def transitionResult

if(issue.getStatus().name.equals("In Progress")){
log.debug "${issue.getCustomFieldValue(envCf)} ${issue.getStatus().name}"
transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId, new IssueInputParametersImpl())

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

if(transitionResult.isValid()){
log.debug "Transitioned issue $issue through action $actionId"

}
else{
log.debug "Transition result is not valid"

}
}
else{
log.debug "The transitionValidation is not valid"

}
}




0 answers

Suggest an answer

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

Jira Cloud Performance Improvements

Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...

158 views 1 8
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