Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Scriptrunner post function move issue to a status

Edited

I use post function Fires an event when condition is true. Event = issue Assigned. In WF i got "Create issue" - status "Open" - status "To do". I need issue to be in the status "to do" if there is an assignee. Can you help me with script to use to move issue to a status "To do".

2 answers

1 accepted

1 vote
Answer accepted

Hi Stanislav, I was able to do something similar to what you are looking for via a Listener, configured to trigger for 'Issue Updated' events :

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

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.issueManager
def issue = issueManager.getIssueObject(event.issue.key)
IssueService issueService = ComponentAccessor.getIssueService()
def actionId = 21 // change this to the step that you want the issues to be transitioned to
def transitionValidationResult
def transitionResult

if (issue.getAssignee() != null) {

transitionValidationResult = issueService.validateTransition(currentUser, issue.id, actionId, new IssueInputParametersImpl())

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

What it does is it checks if the issue has an assignee, and if it does, then whenever the issue is updated, it would perform the transition specified in the actionId (you can find the action ID for the transaction that you want when viewing/editing the workflow, as in the image below :

actionID.png

So in my workflow, the transition action ID to transition an issue to 'In Progress' is 21, so by specifying 21 in the code it knows which transition to perform. You will need to find the action ID specific to your workflow/transition and edit the code accordingly, but it should fulfill what you are looking for.

Hi

What I understand is, you want to transition automatically an issue when issue is assigned, right? 

In this case, I would recommend to you to use Automation for Jira  instead os scriptrunner, will be easier to configure and maintain. 

Right but we dont have Automation for Jira in our company we are using scriptrunner.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Marketplace Partner Spotlight: Fine Software

Happy New Year, everybody! What better way to kick off 2022 than with a new Marketplace Partner Spotlight ✨ This month, we're getting to know Daniel Franz, co-founder of Fine Software. Fine Software ...

429 views 2 15
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