Hey,
I'll be happy to know if there is any way to set by default the Sprint field value to be the same as the current active sprint.
I'm using ScriptRunner, Thanks in advance!
Hi @Yuval Maron
Yes, it is doable. You can put the following script in the Initialiser field:
package examples.docsimport com.atlassian.greenhopper.service.rapid.view.RapidViewServiceimport com.atlassian.greenhopper.service.sprint.SprintIssueServiceimport com.atlassian.greenhopper.service.sprint.SprintManagerimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.onresolve.scriptrunner.runner.customisers.JiraAgileBeanimport com.onresolve.scriptrunner.runner.customisers.WithPlugin/*** Configurable section*/// Enter the board id to which you want to add the issue to the first active sprintdef rapidBoardId = 1L@WithPlugin("com.pyxis.greenhopper.jira")@JiraAgileBeanRapidViewService rapidViewService@JiraAgileBeanSprintIssueService sprintIssueService@JiraAgileBeanSprintManager sprintManagerdef loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()def view = rapidViewService.getRapidView(loggedInUser, rapidBoardId).getValue()// Sprint Fielddef field = getFieldByName("Sprint")if (!view) {log.warn("No view with this ID found")return}// get all sprints in the Rapid Boarddef sprints = sprintManager.getSprintsForView(view).getValue()// find active sprintdef activeSprint = sprints.find { it.active }if (activeSprint) {// set Active Sprint IDfield.setFormValue(activeSprint.id)}
The configuration should be looking like this:
Then, save the Behaviour config with the script. Next, go to the Create Issue screen and you will see the Sprint field has set to the default active sprint.
A recorded demo for your reference - video.mp4
Bear in mind, the script is made for Behaviour. You can reuse the script for other such as post-function or listeners. If that the case, please remove this line:
def field = getFieldByName("Sprint")field.setFormValue(activeSprint.id)
And, replace with other script to get the Sprint custom field name and set to the issue.
I hope this helps.
Hey @John Chin ,
Thank you so much for this!
Hi @Yuval Maron ,
No problem
Feel free to accept the answers if its working for you.
It looks like you're new here. Sign in or register to get started.