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,460,500
Community Members
 
Community Events
176
Community Groups

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

Atlassian Community Events