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

Extract content of deleted comment after ISSUE COMMENT DELETED event in scriptrunner listener Edited

I have set up an ISSUE COMMENT DELETED event in scriptrunner listener. Every time when a user deletes the comment I have to update the backend system to delete the same comment.

Is there any way in scriptrunner listener to find out the comment body of deleted comment?

2 answers

0 votes

No, the event only holds the information about the event, not what the event was acting on.

You've deleted the comment.  By the time the listener picks up the event, the data has gone.

I'd recommend the users of your "backend" system use Jira for the source of the data, rather than duplicate (and hence lose or obsolete) data.

@sbhutada @Nic_Brough__Adaptavist_ 

Sorry but i need to correct Nic Brough on this one, the event does have information about the action you where executing. To get the old comment information u can use the following code:

import org.apache.log4j.Level
import org.apache.log4j.Logger
Logger log = Logger.getLogger("runner.ScriptRunnerImpl")
log.setLevel(Level.DEBUG)
log.setAdditivity(false)

Comment comment = event.params["originalcomment"]

log.info("Whats my id: " + comment.id)
log.info("Whats my body: " + comment.body)
 

It is not stored inside the comment but you are able to find it back in the event params as originalcomment.  It is also always good to print the full event then you can see what information the event contains:

log.info("What is my event: "+ event)


Hope this helps other people to :), good luck everyone happy programming!

No need to apologise for correcting this!  It used to be the case that issue delete had nothing, but it does now.

Like Bart_Joosten likes this

Suggest an answer

Log in or Sign up to answer
TAGS

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