Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automation: delete specific comment using ID

Peng Zhou
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2022

Hello all,

Using automation, I'm trying to get the ID of a specific comment to delete it.

So what I want is:

  1. Resolving Issue A creates a comment in Issue B
  2. Using automation, I can get the ID of the specific comment in Issue B
  3. Using automation, I can delete the comment in Issue B

Where I am is:

  1. Resolving Issue A creates a comment in Issue B
    1. This comment includes the issue key and is a URL to the issue in Jira (see image) image.png

I am stuck here. I can't seem to get the comment ID. I am using the following smart value.

{{#comments}}{{#body.startsWith("text"){{id}}{{/}}{{/}}

This smart value does work. It works when the comments starts literally with text. However, I want to use a smart value instead of "text", but it doesn't work and I get an error message. So it would look like this.

{{#comments}}{{#body.startsWith({{triggerIssue.key}}){{id}}{{/}}{{/}}

 I have tried variations but I only get error messages in the log.

image.png

2 answers

0 votes
Nicolás Figueroa
Contributor
August 10, 2023

Hi, I was trying to get the id created by an own automation because if the user fix the erros the comments should not be there anymore.

So to capture the commentId, I stored it in a automation Variable using:

{{#issue.comments}}{{#if(exists(body.match(".*(YOUR TEXT).*")))}}{{id}}{{/}}{{/}}

This will retrieve the id of the comment which has YOUR TEXT

0 votes
Connor
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 11, 2022

Hi Peng Zhou, why are you adding a comment to Issue B when Issue A is closed, if you're just going to delete the comment anyways? Wouldn't it be simpler to just not create the comment in the first place?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events