Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,464,973
Community Members
 
Community Events
176
Community Groups

Is it possible to change an issue status using Script runner Cloud

Hi,

I am trying to change an issue Status (To Do, In Progress or Done), using the following simple method

// Code 1

def result = put("/rest/api/2/issue/${parentEpicKey}")
.header('Content-Type', 'application/json')
.body([
fields: [
status: "[self:https://domain.com.atlassian.net/rest/api/2/status/3, description:This issue is being actively worked on at the moment by the assignee., iconUrl:https://domain.com.atlassian.net/images/icons/statuses/inprogress.png, name:In Progress, id:3, statusCategory:[self:https://domain.com.atlassian.net/rest/api/2/statuscategory/4, id:4, key:indeterminate, colorName:yellow, name:In Progress]]"
]
])
.asString()
I get the following error : 
{"errorMessages":[],"errors":{"Status":"Field 'Status' cannot be set. It is not on the appropriate screen, or unknown."}}
       |                    false

 

I have already extracted the value of Status for tickets with this :

//Code 2
def fields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map) } as List<Map>

def statusField = fields.find { it.name == 'Status' }
logger.info("statusField : ${statusField}")

which prints the values I am trying to assign to Status in Code 1.

 

Does anyone have any idea please on what I am missing ?

Thank you

 

2 answers

1 accepted

5 votes
Answer accepted
Nir Haimov Community Leader Jan 14, 2019

Hi,

Yes you can, use:

POST /rest/api/3/issue/{issueIdOrKey}/transitions

in your body you need to send:

"transition": {
    "id": "5"
  }

 

Read this:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/?utm_source=%2Fcloud%2Fjira%2Fplatform%2Frest&utm_medium=302#api-api-3-issue-issueIdOrKey-transitions-post

Status is not a field you can just edit, it is an indication of where an issue is in the process.  To change it, you must use a transition to move the issue through it.

Thank you I wasn't aware of that, however the transition is Empty

 

// Get available transitions
def transitions = get("/rest/api/3/issue/${parentEpicKey}/transitions")
.asObject(Map)
.body
.issues as List<Map>
logger.info("transitions: ${transitions}") // Returns Null

// To find the Transition ID, is there any way to not start guessing
// Error "Transition id '2' is not valid for this issue
def result2 = post("/rest/api/3/issue/${parentEpicKey}/transitions")
.header('Content-Type', 'application/json')
.body([
transition: [
"id": "3"
]
])
.asString()

Thank you, I wasn't aware of Transitions however the value seems to be empty to know which ID to send.

// Get available transitions
// Returns Null

def transitions = get("/rest/api/3/issue/${parentEpicKey}/transitions")
.asObject(Map)
.body
.issues as List<Map>
logger.info("transitions: ${transitions}")

// Tried few IDs from the status or just as a guess nothing seems to be working
//"Transition id '3' is not valid for this issue
def result2 = post("/rest/api/3/issue/${parentEpicKey}/transitions")
.header('Content-Type', 'application/json')
.body([
transition: [
"id": "3"
]
])
.asString()

You need to use a transition that exists and your user has permission to use.  This depends on what status the issue is currently in and what your workflow says.

Worked like a charm, Thank you @Nir Haimov and @Nic Brough -Adaptavist- for the support, Appreciated 

hey can u help me u do u do that ?

@Mohammed-Amine Rouh
I suppose you have found the answer, as this thread is more than 3 years old. Anyway for others (like me): you may find the transition ID in the workflow configuration, text mode.

Transition_ID.png

Suggest an answer

Log in or Sign up to answer