The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I paste my code created: is working perfectly!
1) I got to the Script Listener menu
2) Here, I select the Custom Script
3) In the Custom Script Menu, I enter the name "Test", the event that I select is "Sprint Started Event", and I insert the code above into the Inline Script.
4) To proceed, I need to know what is the id of the status i.e. actionId.
To explain, below I have added another video which displays the Workflow. From here I select the view option to view workflow which I am going to use i.e. SIMP.
Once I'm in the workflow page, I can see the Transitions (id). The transition name is what I am going to use in the if / else condition i.e.
this is the code attached:
com.atlassian.greenhopper.service.rapid.view.RapidViewService import com.atlassian.greenhopper.service.sprint.Sprint import com.atlassian.greenhopper.web.rapid.chart.HistoricSprintDataFactory import com.atlassian.jira.component.ComponentAccessor import com.onresolve.scriptrunner.runner.customisers.PluginModuleCompilationCustomiser import com.onresolve.scriptrunner.runner.customisers.WithPlugin @WithPlugin("com.pyxis.greenhopper.jira") def historicSprintDataFactory = PluginModuleCompilationCustomiser.getGreenHopperBean(HistoricSprintDataFactory) def rapidViewService = PluginModuleCompilationCustomiser.getGreenHopperBean(RapidViewService) def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser() def sprint = event.sprint as Sprint def sprintState = sprint.state if (sprintState == Sprint.State.ACTIVE) { def view = rapidViewService.getRapidView(user, sprint.rapidViewId).value def sprintContents = historicSprintDataFactory.getSprintOriginalContents(user, view, sprint) def sprintData = sprintContents.value def issueService = ComponentAccessor.getIssueService() // this is the id of the transition you want to make // to get the transition ID, you can refer to your workflows def actionId = 21 if (sprintData) { def issues = sprintData.contents.issuesNotCompletedInCurrentSprint issues.each { issue -> def issueId = issue.id log.warn issue.statusName //to get the status name if(issue.statusName == "To Do" || issue.statusName == "In Progress") { def issueInputParameters = issueService.newIssueInputParameters() def transitionValidationResult = issueService.validateTransition(user, issueId, actionId, issueInputParameters) if (transitionValidationResult.isValid()) { issueService.transition(user, transitionValidationResult) } else { log.warn transitionValidationResult.errorCollection.errorMessages } } else { log.warn "Nothing to do" } } } }
👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events