Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×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.docs
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.sprint.SprintIssueService
import com.atlassian.greenhopper.service.sprint.SprintManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
/**
* Configurable section
*/
// Enter the board id to which you want to add the issue to the first active sprint
def rapidBoardId = 1L
@WithPlugin("com.pyxis.greenhopper.jira")
@JiraAgileBean
RapidViewService rapidViewService
@JiraAgileBean
SprintIssueService sprintIssueService
@JiraAgileBean
SprintManager sprintManager
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def view = rapidViewService.getRapidView(loggedInUser, rapidBoardId).getValue()
// Sprint Field
def field = getFieldByName("Sprint")
if (!view) {
log.warn("No view with this ID found")
return
}
// get all sprints in the Rapid Board
def sprints = sprintManager.getSprintsForView(view).getValue()
// find active sprint
def activeSprint = sprints.find { it.active }
if (activeSprint) {
// set Active Sprint ID
field.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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.