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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script to delete all comments

I am attempting to write a bit of code that will be used as a scriptrunner postfunction. The goal is that when an issue gets transitioned all of the comments get deleted.


So far I have come up with this

.header("Content-Type", "application/json")


but I get an error about the comment

CorrelationId: 894d7210-838d-4549-b5ea-cf7bbb005c07
RUN Script identifier: 9e6a3000-0bd1-4fa4-9545-d301488a8259  Took: 100ms Logs:
2019-12-26 23:20:37.553 ERROR - No such property: comment for class: Script1 on line 4
2019-12-26 23:20:37.572 ERROR - Class:, Config: [:]


What am I doing wrong here? Im having trouble finding information about deleting with scriptrunner.


Ive also looked at the atlassian documentation and the delete comment command but I dont really understand how to translate the api request into a scriptrunner script.


any help would be appreciated.


1 answer

0 votes
brbojorque Community Leader Dec 26, 2019

Can you include your script so we can take a look?

Hi Bryan,

This is what I was trying


.header("Content-Type", "application/json")
brbojorque Community Leader Dec 29, 2019

Hi @Alexander Piwowar ,

Apologies for the delay, please do check the script I have attached.

Pseudo code:

  • Get all the comments in an issue
  • Loop over the comments and delete it.
def response = get('/rest/api/3/issue/TP4-1/comment').header('Content-Type', 'application/json').asObject(Map)

def comments = response.body.comments

delete(it.self.toString()).header('Content-Type', 'application/json').asObject(Map)
Like Hana Kučerová likes this

Oh wow that worked, thanks.


May I ask, how do you figure all of this out?


In the first line what does the .header do? and the Map?

Where do you the it.self from in the loop?

brbojorque Community Leader Jan 12, 2020

Hi @Alexander Piwowar ,

I referred the ScriptRunner cloud documentation.

It should help you if you want to integrate additional functionality using ScriptRunner.

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you