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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

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

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
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

265 views 2 5
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