Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 Marketplace Apps & Integrations

New cloud apps roundup - June 2021

Since our last roundup in April, Atlassian's Marketplace Partners have added over 100 new cloud apps to the Atlassian Marketplace to help your teams work more efficiently. Let’s take a quick look a...

487 views 6 12
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