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,462,134
Community Members
 
Community Events
176
Community Groups

is it possible to set stepid from a groovy script?

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 ?  

2 answers

1 accepted

0 votes
Answer accepted

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

image.png

Once i changed this to 

image.png

My script start to work as expected 

0 votes

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.

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

 

image.png

It shall look like this

image.png

 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events