Sharing the steps to create a Jira Automation Rule to delete all Comments from an Issue (when a new comment is added to that Issue):
1. Rule is triggered on: Issue Commented
- Comment Type: All Comments
2. Advanced compare condition:
- First value: {{issue.key}}
- Condition: equals
- Second Value: enter your Issue Key here (example: P-123)
3. Advanced Branching: (this will fetch the list of all Comment Ids of this Issue)
- Smart value: {{#issue.comments}}{{id}}{{/}}
- Variable name: commentId (Note: this is a user-defined Smart value variable)
4. Select action: "Delete Comment" (will be executed for for each "commentId")
- Comment id: {{commentId}}
-------------------------------------
Rule Logic:
This rule will trigger for a specific Jira Issue (based on the compare condition),
- and it will fetch the list of all comment Ids for that Issue,
- and then, for each comment id, it will execute the action "Delete Comment".
Note: The Jira Automation action "Delete Comment" cannot be executed on a list of Comment Ids. So, we need to pass only a single Comment Id at a time to this "Delete Comment" action.