Jira Automation - Look for existing issue and comment

Anderson Sato March 20, 2024

Hi there, 

We have a simple automation rule that creates a ticket whenever we receive the incoming webhook. The problem is that sometimes we receive updates from the same subject through the webhook. 

So, I was willing to perform a quick lookup on the created issues and instead of creating a new issue, comment on the existing one. 

Knowing that the summary will be the same, I think I can achieve that. 

I was trying to perform a JQL lookup and then use if conditions in case {{lookupissues.size}} was not equal 0, but I can't figure it out how to post the comment in the results of the JQL lookup.

This is the current automation rule

LHr8RsJQ8K.png 

I thought this would be the end result, but I can't figure out how to add the comments from the list of issues of the `lookup issues` component.  

rrHjJh5GrE.png

Any advice?

2 answers

1 accepted

1 vote
Answer accepted
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 20, 2024

Hi @Anderson Sato and welcome to the community!

It looks like you're on the right track.  While the lookup issues action will get you the ability to find whether a duplicate exists, you ultimately need to branch into the duplicate.  So under your Else you'll want to add a Branch based upon the same JQL as your lookup issues JQL to iterate through the duplicate issues.  Then you can include your Add Comment action within the branch.

Anderson Sato March 20, 2024

Hi @Mark Segall , thanks for assisting me on that. 

I'm actually having a hard time on the branch. When you say that I would need to branch into the duplicate would be something like that?

8dNKZw3jJH.png

I don't quite get why I need to specify the smart value and then declare a variable. I'm quite new in Jira Automation, so apologies if that is some basic concept.

Or what you actually say is to do the following?

ot4eClxeHG.png

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 20, 2024

It's the second approach.  You're branching into the issue(s) that share the same summary as your webhook trigger.  I say "iterate" because the branch will work for one or many summary matches.

Anderson Sato March 20, 2024

Nice, I will update the rule and once I validate it works I will accept your answer. Thanks!

Like Mark Segall likes this
Anderson Sato April 19, 2024

Thanks @Mark Segall it worked. I needed to tweak a little my JQL as it contained some special characters, but all seems to be working. 

Like Mark Segall likes this
Anderson Sato May 1, 2024

Hey @Mark Segall so it seems that I'm still missing something. Sorry to bother you again. 

My initial if condition was not working properly so I've made some changes to fix it with no success. 

The comparison of smart value {{lookupissues.size}} is not working and I don't know why. As you can see below from the rule and logs, the {{lookupissues.size}} is 1, but instead of executing the if block it executes the else. I've tried to change the condition to not equal 0, but then it always executes the if block.

Jira-Automation.pngJira-Automation-2.png

Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 1, 2024

Hi @Anderson Sato - Very interesting.  Everything looks correct.  The only thing I see is that the condition is not following the same case as the log action (lookupIssues vs lookupissues.  This should not matter, but try using the same case in your condition as you're using in your log action with I capitalized.

If this makes no difference (as I suspect it shouldn't), perhaps try forcing it to treat the value as a number (again... something that shouldn't be required) using this:

{{lookupIssues.size.asNumber}}

Hopefully one of these solves the issue, but from what you shared these extra steps shouldn't be required. 

Like Kalyan Sattaluri likes this
Anderson Sato May 1, 2024

Thanks for the quick reply @Mark Segall , I will try that.

I appreciate your help.

Kalyan Sattaluri
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.
May 1, 2024

Good call @Mark Segall  lookupIssues is case sensitive. lookupissues will not work.

Anderson Sato May 15, 2024

Hi guys,

Sorry for my absence on the subject. It seems that even modifying the condition to be case sensitive and forcing the interpretation as a number, it still doesn't work.

I have seen this case where it was suggested to add

{{lookupIssues.size|0}}

The "size|0" adds a default value of zero when no issues match the JQL for the lookup. If that's the case I will need to change my if-else block.

https://community.atlassian.com/t5/Jira-questions/Using-the-lookupIssues-to-find-number-of-issues-in-an-Epic/qaq-p/1681084

Any other thoughts?

dSawT5WFOt.pngjBxt8nUgVZ.png

Elmedin Jasic
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!
May 22, 2024

Hi

I'm working on something similar and while trying to branch the issues and drop a comment, I got an error saying:
Error searching for related issues. This is most likely because the following issues don't have a related issue of the type you specified.

What exactly does it mean 'related issues'?
Do the issues have to be linked or something like that?

I've also tried a different approach - advanced branching with lookupIssues.key as the smart value, but that fails as well with the error:

Error adding comment to issue

Issue does not exist or you do not have permission to see it.

Any help is appreciated.


EDIT:
Using just lookupIssues in the advanced branching option kinda works, but instead of commenting on all the tickets it found, it left as many comments on the trigger issue as it found tickets which isn't super useful for my case

Anderson Sato July 9, 2024

Just a quick followup on this. I managed to find a workaround using regex. I still don't understand why it didn't work with previous conditions.

94eyneAOoq.png

@Elmedin Jasic, sorry to not reply you earlier, but I felt that I did not have the knowledge to help you. Yet if you want, elaborate a little more your automation rule and I will try to assist you better.

0 votes
Kalyan Sattaluri
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.
March 20, 2024

Hello @Anderson Sato 

In your trigger of incoming webhook, do a JQL search with same criteria as you have in lookup JQL. Then in your Else condition, you can edit that issue and put your comment.

 

image.png

Anderson Sato March 20, 2024

Hi @Kalyan Sattaluri ,

In this scenario I'm performing a lookup direcly in the trigger, is that it? I actually use the webook smart value to look for the issue summary. Without it I can't do the JQL lookup.

I tried to see the documentation on this option, but I couldn't find any. 

Kalyan Sattaluri
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.
March 20, 2024

No, my suggestion was to do JQL in trigger "in addition" to doing your lookupIssues JQL.

BTW, Just FYI - You can directly reference webhook smartvalue in JQL. You dont need intermediate variable called {{summary}}.

I think @Mark Segall  suggestion should also work so thats another approach.

Suggest an answer

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

Atlassian Community Events