Unable to add an issue to a current sprint using Jira Process Automation

Tim Moffatt January 3, 2024

I'm trying to use Jira issues for a help desk.  When a new issue is received I want it to get added to the current sprint so it can get worked by the helpdesk team.  We have 1 project and that project has several agile boards active at the same time.  So I need to be able to assign it to the active sprint on a specific agile board automatically.  

 

When I try to add an issue to a current sprint using Jira process automation I get the following error: 

No fields or field values to edit for issues (could be due to some field values not existing in a given project):

 

This is what my edit issue block looks like: 

Capture1.PNGAnd when I try to run the automation this is the error message I get;

Capture2.PNG

 

I have confirmed the actor on the automation flow has permission to edit the sprints.  And if I manually assign the issue to the sprint after it's opened I can get the ID number of the active sprint. 

 

I need to find some way to either use the automation to add the issue to the active sprint, or I need to find a way to use an advanced Smart Value edit to assign the issue to the ID number for the current sprint.  But I don't want to manually edit the sprint number every 2 weeks.  I need to have it automatically grab the id number for the newest sprint every time this flow runs,  

 

2 answers

0 votes
Hauke Bruno Wollentin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2024

Sadly we have the same issue and are not able to resolve it within Automation.

Like you we checked the permissions, sprints, boards etc and everything seems good (also this rule worked before without any issue).

If you have ScriptRunner you can do the following hack.

We'd put this into static methods to be able to call this from within Automation with the ScriptRunner action.

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

import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager

// Variables to use as method parameters
Long boardId = 17
String issueKey = "HAUKE-10"

// Various managers and services
RapidViewService rapidViewService = ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewService)
SprintService sprintService = ComponentAccessor.getOSGiComponentInstanceOfType(SprintService)
CustomFieldManager cfManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()

// Current user
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()


// Fetch the ACTIVE sprint of the board
def board = rapidViewService.getRapidView(currentUser, boardId).get()
def State = Sprint.getClasses()[1]
def sprintQueryActiveSprints = SprintQuery.builder().states(Collections.singleton(State.ACTIVE)).build()
def sprintQueryFromBoard = sprintService.getSprints(currentUser, board, PageRequests.all(), sprintQueryActiveSprints)
Sprint sprint = sprintQueryFromBoard.get().getValues().first()

// Get issue object
def issue = Issues.getByKey(issueKey) as MutableIssue

// Get sprint custom field
def sprintCf = cfManager.getCustomFieldObjectsByName("Sprint").first()

// Set sprint to issue and update the issue
issue.setCustomFieldValue(sprintCf, [sprint])
issueManager.updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false)

 

0 votes
Rebekka Heilmann _viadee_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2024

Just a wild guess, but did you add the "Sprint" field to the Screen Config?

Tim Moffatt January 4, 2024

Is this what you mean? 

Capture3.PNG

Rebekka Heilmann _viadee_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2024

Yes. I tested the rule myself. It worked for me.

Some other guesses, as it's difficult to know for sure without having access to the issue, the board and so forth.

- there is no active sprint when you execute the rule

- you execute the rule on an issue, that is not part of the board's filter (which cannot be true, if the issue appears in the backlog or you can move it manually)

Both are unlikely. Sorry I cannot help further

Tim Moffatt January 4, 2024

hmmm....  there definitely is an active sprint when the ticket's created.  and the board filters are set to the components, i.e. the "DPA Development" component is set to show on the DPA Sprint board.  

 

I wonder.. what if I was to do this?

1 - Use a step in the automation to search for the Sprint's ID number, store it as a variable,

2- Then use an advanced Edit Issue action to do a JSON command to edit the custom field on the issue labelled "Sprint" etc. and update it from a "Null" value to the ID number from the variable? 

Rebekka Heilmann _viadee_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 4, 2024

You don't need a Sprint ID. Using the "Active Sprint" function as you did in your screenshot works perfectly fine - at least in my case ;) 

But sure, you can try that out. But maybe someone else in the community had your issue before and will be able to help more than I.

Suggest an answer

Log in or Sign up to answer