Forums

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

Transitioning issue whereas adding comment

Mayur Gaikwad/Tech PMO
Contributor
December 21, 2023

Hi

using below code in scriptrunner, I'm able to transition issue but unable to add comment simultaneously.

Seems syntax issue when I'm using ".body comment"

 

def issueKey = issue.key
def transitionID = '381'

 

// The rest call to transition the issue
def result = post("/rest/api/2/issue/${issue.key}/transitions")
        .header("Content-Type", "application/json")
        .body([transition: [id: transitionID]])
        .asObject(Map)

 

 

if (result.status == 204) {
    logger.info("The ${issue.key} issue was transitioned by the escalation service.")
} else {
    logger.warn("The escalation service failed to transition the ${issue.key}issue. ${result.status}: ${result.body}")
}

 

// Add a return message to show which issues the escalation service ran on.
return "Escalation Service completed on ${issue.key}"

1 answer

0 votes
Evgenii
Community Champion
December 21, 2023

Hi, @Mayur Gaikwad/Tech PMO 

You can make it by additional action in script

def comment = """TEST COMMENT TEXT"""

def addComment = post("/rest/servicedeskapi/request/${issue.key}/comment")
.header('Content-Type', 'application/json')
.body([
body: comment,
])
.asObject(Map)

Suggest an answer

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

Atlassian Community Events