The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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)
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events