You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I can transition an issue with a scriptrunner listnern and a groovy script, but the status name is not correct after transition, but my ticket is in the right position for next transition.
is there a way to hard code the status name value ?
I think i have found the reason why it did not work.
the Post Function step have the following tirgger
Fire a Issue Resolved event that can be processed by the listeners.
And in my script listner my last event is Issue Update
Once i changed this to
My script start to work as expected
If you are transitioning an issue correctly (i.e. not setting a step id, but going through a transition), then the status will be correct.
I think you need to show us what you are doing in your script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
If i use the script below in scriptrunner console and transition my ticket to just befor the requested automation it works perfectly.
But the "same" script (the if-statment for installation is the first thing i check in the listner otherwise all is the same. ) the issue is transition but the status value is incorrect.
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.workflow.WorkflowManager
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowException
import com.atlassian.jira.bc.issue.IssueService.UpdateValidationResult
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.bc.issue.IssueService
// Get a pointer to the issue
//----Activate if Consloe is used----------------------------------------------------
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("ICTSHH-4917")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
//-------------------------------------------------------------------------------------*/
if (issue.getStatus().getName() == "Installation"){
log.warn("Issue has status Installation")
Issue issueKey = issue
log.warn("issueKey = " + issueKey)
def LinkManagerissue = ComponentAccessor.getIssueLinkManager()
def issueLinks = LinkManagerissue.getInwardLinks(issueKey.getId())
def transitionResult
def workFlowManager = ComponentAccessor.getWorkflowManager()
def workflow = workFlowManager.getWorkflow(issue)
//-----Check what id's are available for transistions
//return workflow.getLinkedStep(issue.getStatus()).getActions().id
def actionId = 421
IssueService issueService = ComponentAccessor.getIssueService()
def transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId,new IssueInputParametersImpl())
def issueInputParameters = issueService.newIssueInputParameters()
//------Check if transittion is possible
if (transitionValidationResult.isValid()) {
transitionResult = issueService.transition(currentUser, transitionValidationResult)
if (transitionResult.isValid())
{ log.warn("Transitioned issue $issue through action $actionId") }
else
{ log.warn("The transitionValidation is not valid")}
}
// validate update -------------
UpdateValidationResult updateValidationResult = issueService.validateUpdate(currentUser, issue.getId(), issueInputParameters)
//return UpdateValidationResult
return updateValidationResult.isValid()
if (updateValidationResult.isValid()){
// update the issue ----------
issueInputParameters.setStatusId("CUSTOMER ACCEPTANCE")
IssueResult updateResult = issueService.update(currentUser, updateValidationResult)
if (!updateResult.isValid()){
log.warn("error updateResult: " + updateResult.getErrorCollection().toString())}
} else {
log.warn("error: updateValidationResult" + updateValidationResult.getErrorCollection().toString())}
}
Below is the result i get using scriptrunner listeners
It shall look like this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.