---
title: "Fetch the current active sprint of a Scrum board"
canonical: "https://support.appfire.com/space/JMWE/462062102/Fetch%20the%20current%20active%20sprint%20of%20a%20Scrum%20board"
format: markdown
---
> Macro (aura-html)

### Abstract

This code snippet fetches the current active sprint of a Scrum board.

### Logic

Fetch the active sprints applicable to the current user and specified board and get the first sprint.

### Snippet

```groovy
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.sprint.SprintService
import com.atlassian.greenhopper.service.PageRequests
import com.atlassian.greenhopper.service.sprint.SprintQuery
import com.atlassian.greenhopper.service.sprint.Sprint
import com.atlassian.greenhopper.service.sprint.Sprint.State

def boardId = <Board Id>
def board = getComponent(RapidViewService).getRapidView(currentUser, boardId).get()
def SprintService = getComponent(SprintService)
def State = Sprint.getClasses()[1]

def sprintQuery = SprintQuery.builder().states(Collections.singleton(State.ACTIVE)).build()
def sprintsOutcome = SprintService.getSprints(currentUser, board, PageRequests.all(), sprintQuery)

if (sprintsOutcome.isInvalid()){
  throw new UnsupportedOperationException(sprintsOutcome.toString())
}
def sprints = sprintsOutcome.get().getValues()

if (sprints.size() == 0){
  throw new UnsupportedOperationException("No active sprints")
}
if (sprints.size() > 1){
  throw new UnsupportedOperationException("More than one sprint is active")
}
return sprints[0].getId()
```

### Placeholders

| **Placeholder** | **Description** | **Example** |
| --- | --- | --- |
| `<Board Id>` | <span style="color: #222222">N</span><span style="color: #222222">umerical ID of the Scrum board</span> | `2` |

### Examples

<span style="color: #333333">The outcome of the code snippet is the current active sprint of the board which you could use to set the Sprint of an issue in one of the Set field value post-functions for example to Add the issue to the current active sprint.</span>

### References

- [getComponent()](https://appfire.atlassian.net/wiki/spaces/JMWE/pages/461799437)
- [**Groovy Documentation**](http://groovy.codehaus.org/User+Guide)

### Related articles

> Macro (contentbylabel)

> Macro (details)
> 
> | **Related issues** |  |
> | --- | --- |