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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.