/
Delete all comments of an issue.
Delete all comments of an issue.
This article provides the code snippet to delete all comments of the current issue using Build-your-own (scripted) Post-function post-function, callJira Nunjucks filter, and this Jira Cloud REST API.
Instructions
Navigate to the intended workflow and open it in Edit mode.
Select the required transition.
Select the Post functions tab and click
Add post function
.Add the Build-your-own (scripted) Post-function post-function.
Add the below code in “Nunjucks script”:
{% set allComments = issue.fields.comment.comments | field("id") %} {% for comm in allComments %} {{ "/rest/api/2/issue/:issueKey/comment/:id" | callJira( params={issueKey:issue.key,id:comm}, verb="delete" )}} {% endfor %}
Add the post-function and publish the workflow.
With this, all the comments on the current issue are deleted when the transition is executed.
Note that once comments are deleted, they cannot be restored. So please implement this script with caution.
References
Related articles
Related content
callRest
callRest
Read with this
deleteComment
deleteComment
More like this
Custom Filters
Custom Filters
Read with this
deleteComment
deleteComment
More like this
Copy comments to related issues
Copy comments to related issues
More like this
deleteComment
deleteComment
More like this