Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Assign a new issue to a named sprint automaticly

Thomas Johannessen June 2, 2023

We have a situation with out system development-department where we want all cases in the backlog to be shown on the "Board" in status Todo. We will have multiple sprints active at the same time depending on how the feature will be developed. To show a newly created case on the board it has to be added to a sprint. We have therfor created a sprint we want to add all the new cases to(to work like a backlog but show up on the Board). There will be too many new cases to do this job manully, and we therfor want to use atomation for this. The trigger will be "issue created", and we wwant the result to ba that the issue is added to the named sprint. Since we will have multiple active sprint simultaneously so it is not possible to use the action "edit issue" and the "Sprint" filed on the issue, since here we only have the possibility to choose the active or the next sprint(since we have multiple sprint active and will create new sprint later). I therefore think the solution will be to find the Smart value where the sprint data is stored, and updated this, but i find it hard to find the correct field and how to update it with the JSON. I have tried to find the value fith the sprint-data using the REST APIs, but it seems like the keys and fields in the API is different regards to the sprint-info on different issues, even though both issuestypes have the sprint fiield. Can someone assiste me in how i should do this in Jira Cloud?

2 answers

1 accepted

1 vote
Answer accepted
Trudy Claspill
Community Champion
June 2, 2023

Hello @Thomas Johannessen 

Welcome to the Atlassian community.

Take a look at the answer from @Alex Koxaras -Relational-  on this post.

Thomas Johannessen June 2, 2023

Hi, thank you so much @Trudy Claspill . It seems like he wants to do the same i want, but unfortuntly it seems like it does not work for me. I get the id of the sprint i want to assigne it to(39), but when i do the last part in the action, i get "Additional fields contains invalid field(s) in 'update' or 'fields' section: SprintSkjermbilde 2023-06-02 182419.png

If i use the REST API on the issue, i dont see the "Sprint" as a vlaue there, so this makes sense i think. But i see that i have the info about the sprint the issue is assigned to in this field:
Skjermbilde 2023-06-021 182616.png

48 is the ID of the sprint its assigned to now. Im not sure if this is just info of if changing this has any impact on which sprint its in. But when i try to change this i get an error:

Skjermbilde 2023-06-022 184308.png

I try to change it like this:

Skjermbilde 2023-06-023 184551.png

(Have tried with one less } at the end also)


Do you have any idea what i do wrong?

Trudy Claspill
Community Champion
June 2, 2023

See the comment from @Bill Sheboy 

Bill Sheboy
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.
June 2, 2023

Let's stick to this thread as that is where the rule image is posted.

After the change to remove the extra bracket please post new images of your rule and the audit log details showing the rule execution.  Thanks!

Thomas Johannessen June 2, 2023

Hi, thank you.
Skjermbilde 2023-06-025 200147.pngSkjermbilde 2023-06-024 200054.png

Here are them after removing one bracket. Thank you

Trudy Claspill
Community Champion
June 2, 2023

I have experienced the same error ("must be a number") trying to set the Sprint field on an issue with this JSON code, though this matches the information in the post I found with Alex's answer.

{
"fields": {
"sprint": { "id": 58 }
}
}

 I have also tried

{
"fields": {
"sprint": { "id": "58" }
}
}

And I've tried creating a variable, setting the variable's value to 58, and then using the variable in the JSON.

{
"fields": {
"sprint": { "id": {{SprintIdVariable.asNumber}} }
}
}
Like # people like this
Thomas Johannessen June 2, 2023

Hi, did these work for you?

When i try i gte the error that Sprint-field do not exist. Any idea what is the reason behind this?
Skjermbilde 2023-06-026 202934.png

Any more suggestions on what i can try?

Trudy Claspill
Community Champion
June 2, 2023

In my rule regardless of whether I used "Sprint" or "sprint" in the JSON I got this error:

Number value expected as the Sprint id., The Sprint (id) must be a number (customfield_10020)

If you getting the "invalid field(s)" message that suggests that the Sprint field is not included on the Edit screen that is used for the issue type you are trying to edit in your rule.

Can you edit the Sprint field directly through the UI for that type of issue in the target project?

Thomas Johannessen June 2, 2023

Hi, 
Okey i see that i dont have the sprint field in the fields when i call the REST-API on the issue eigther. I can edit the sprint in these field, and choose any of the other fields.

Skjermbilde 2023-06-027 205703.png
Only thing i have on the issue in the rest api that is connected to the sprint is the customfield_10021.

Thomas Johannessen June 2, 2023

Skjermbilde 2023-06-028 211301.png
The sprint field is on the issue type, and as you can se above it is filled out

Thomas Johannessen June 2, 2023

Hi, i see that i the XML i can see the name of the customfields , and the customfield_10021 is the Sprint.
Skjermbilde 2023-06-029 212107.png

Trudy Claspill
Community Champion
June 2, 2023

I figured out how to solve the "must be a number" error.

The JSON code should be this:

{
"fields": {
"sprint": 58
}
}

I see from your image that you are working on an Automation rule for a Team Managed project. I tried the above in a Team Managed project using both sprint and customfield_##### and in both cases it worked.

(I'm not sure where I got the code that used {"id": number} . I think maybe I pulled that inadvertently from another document since I see in Alex's answer it was just "sprint": number )

Like Thomas Johannessen likes this
Thomas Johannessen June 2, 2023

Hi, thank you so much for the help! You have been so helpfull! This almost worked for me... When i use the "sprint" field it failed:

Skjermbilde 2023-06-0210 213732.png

But when i changed the name to the custom field IT WORKED!!

Skjermbilde 2023-06-0211 214045.png

Skjermbilde 2023-06-0212 214318.png

If works now, and im so greatfull! Thank you so much for your help and that you took your time to help me!


For anyone else having this issue:

Use https://XX.atlassian.net/rest/api/2/issue/XXX-XX (XX is the jira area and XXX-XX is the issue id)

Here you have all the info you need about the issue. Search for the sprint name or the sprint id.

Find the sprint id you want toassign it to, and use this as in my example above.

Like # people like this
0 votes
Bill Sheboy
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.
June 2, 2023

Hi @Thomas Johannessen -- Welcome to the Atlassian Community!

First thing: I suggest you sit down with your Jira site admin to ask for help.  Your scenario seems complicated and it will help to directly discuss this with the admin.

What you seem to be asking is...

  1. you have a project with multiple active sprints
  2. you do not describe the relationship between the active sprints and any single/multiple boards
  3. when an issue is created, you want it added to an active sprint
  4. you do not describe how it is decided to which sprint the new issue will be assigned

Regarding #3 and #4, I recommend discussing this with your team's Scrum Master or Agile Coach.  Adding issues to an in-progress sprint should be an exception, and not such a common practice that a team needs an automation rule to do so.

Let's assume your Scrum Master/Agile Coach still agrees with this approach...then #4 is key, as you would need to call the REST API to search all the sprints to find the one to use.  Then add the issue to that sprint using the sprintId value.

Kind regards,
Bill

Thomas Johannessen June 2, 2023

Hi, we are a small department who handles this, so we do not have anyone with this advanced knowlegde unfortantly. I know this is not best way to use Jira, but this is how the department whants it. We will have multiple simuntainisly sprints(one for each supplier which does the fixing and developing for us, which some will be many short, and other few long once). The department wants to show everything that is in the backlog on the standard "Board" in a todo status. To be able to show new issues on the bord we have created a sprint until year 9999 which will do the exact same thing as the backlog(we will move them with this automation out of backlog the moment they are created, and therfore never have anything in the backlog and use this sprint as the backlog insted.) If you see my answer to Trudy it may be a bit clearer what i want and how i want to do it. Thank you so much for your sugestions.

Bill Sheboy
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.
June 2, 2023

Thanks, and as both Trudy and I noted you will need to use the REST API to gather the sprints and then search for the value needed.

Regarding the error you see with the JSON, the number of left/right curly brackets must be balanced, and you appear to have one too many.

Thomas Johannessen June 2, 2023

Hi, if i dont have missunderstood your answer i think i describes the problem better in Trudys answer. I have tried with one fewer curly brases but same error. Do you know what can be the error or next step to try? Do my syntax looks correct except the last curly brase?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events