Jira Automation rule to delete all comments

ROHIT VERMA
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 20, 2023

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.

1 comment

Comment

Log in or Sign up to comment
Suraj Gurav April 17, 2024

@ROHIT VERMA Looks like Advanced Branching feature is removed from Jira.

I am trying to setup an Automation where comments from a specific user can be removed when Issue transitions from 'In Progress' to 'Done'. With your suggested way, I got list of all comment Ids as a Json Array. Do you know, how we can get a specific comment if out of it?

Thanks

ROHIT VERMA
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 17, 2024

You will need to change my original series of steps and try along the following lines:

Step 1 (When): Rule is triggered on:

"Issue Transitioned" from "In Progress" to "Done".

 

Step 2 (Condition): Status equals Done

 

Step 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)

 

Step 4: If (smart values condition):

First value: {{issue.comments.author.displayName}}

Condition: equals

Second Value: "user's display name"

 

Step 5: Then (Action):

Remove comment from issue

Comment Id: {{commentId}}

 

This automation rule will delete all comments by the specific user when the status of any issue changes from 'In Progress' to 'Done'.

 

Caution: Implement and test this rule on a test Jira issue before rolling out in production.

TAGS
AUG Leaders

Atlassian Community Events