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?
@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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Bart_Joosten , thanks a lot for your solution. That's great! I used it in ScriptRunner Listener to send email notification for comment added/updated/deleted cases.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.