Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automation Advanced compare condition - comment author

Hi there! Newbie here :) 

I'm trying to set up an automation rule that sends comments into a Slack channel when a specific user is mentioned, the assignee or reporter. 

I'm using the Advanced compare condition and this is my initial if statement to check if the user is the one commenting. This doesn't seem to work as I would like it (I figured it's me who misunderstood something) because it just passes the first IF statement no matter who comments :)  
----
If: Compare two values
Checks if: 
First value:
{{issue.comments.author}}

Condition
Does not match regular expression

Regular expression
.*\[~5ecd20a9730ec90c1988740c:.+\].* 
----
I have double-checked the ID should match the user. 

I tried following these two Questions: 
Solved: How to trigger automation action if comment contai... (atlassian.com)
Solved: How to make a rule that triggers an action when a ... (atlassian.com)

This is all of the automation. 

Automation issue.PNG

2 answers

2 accepted

1 vote
Answer accepted

@Niklas Missel

I'm not sure why you need all those extra things in your regular expression. Mine worked just fine like this:

Screen Shot 2021-02-11 at 10.12.23 AM.png

Okay, it still doesn't seem to do the trick. The user still gets a slack message when they comment themselves.

@Niklas Missel

How did you get their account ID? As I said, this rule worked just fine for me.

@Kian Stack Mumo Systems I got it by going to the admin user page --> clicking on the user --> see the Account ID In the URL. 

I confirmed the Account ID by following Wwalser's suggestion (See comment below):Automation issue.PNG

@Niklas Missel

I think you just need the portion located AFTER the "accountid:". When I log just the author of a comment, it does not contain the accountid: segment.

@Kian Stack Mumo Systems I just tried using my own AccountID (didn't want to bother the user anymore). 

Nothing changes; it passes when I comment on an issue. 

 

Automation issue3.PNG

Ha! I think I have an idea. Let's try this. Update your condition to the following -

 

{{issue.comments.last.author}}

So far so good, it seems to work with my own ID. I'm waiting for the user to try :) 

If that's what needed... well you are truly the hero. And I think makes sense why (just writing it out to see if I fully understand); When I used {{issue.comments.author}} it took the author of the first comment and not the latest right?

Will give you an update soon (hopefully good)!

@Niklas Missel, it took the authors of EVERY comment. The reason that the first suggestion I made worked for me was that I only logged a single comment, so there was only one value in my list. 

Like Niklas Missel likes this

That makes sense,.thanks for clarifying. 

I verified that it now works with the user - thank you for your help! 

1 vote
Answer accepted
wwalser Atlassian Team Feb 12, 2021

First, you're using `does not match` which is generally going to match lots of things. Anything that doesn't match the regular expression.

Also, this regex:

.*\[~5ecd20a9730ec90c1988740c:.+\].* 

doesn't contain the accountid: portion of a user mention. Both of the threads you linked used `.*\[accountid:~.+\].*`. The "accountid:" portion is meaningful.

So what I'm trying to achieve with this part of the statement is that whenever this specific user comments on an issue it shouldn't send a slack message. But if anyone else comments, where the user is either a reporter, assignee, or mentioned, a slack message is created. I'm not sure if the way I did it is either the best way or if it's correct. 

If there is a better way I'm all ears and eager to learn :)

wwalser Atlassian Team Feb 12, 2021

Is 5ecd20a9730ec90c1988740c the account id? Jira / Atlassian use a couple of different representations of users. Internal to Jira it uses account ids which are usually of the shape `numbers:letters-numbers-l&n-l&n-l&n`.

You can figure this out by creating a simple rule which sends their account id to the audit log by logging a comment which mentions them:

Screen Shot 2021-02-13 at 3.20.06 pm.png

After that, use that exact account id in the regex:

.*\[~accountid:557057:fdddddd-6633-46a3-9acf-123456789da2\].* 

It seems to be the same AccountID as I tried earlier, although it doesn't seem to match what you described it should look like.  

Automation issue.PNG


I have tried to update the RegEx with "accountid:...", it still just passes everything. Is there another way I can achieve my goal of not letting it pass a comment from a specific user?  Or do you have some other comments on what I do wrong? 

Automation issue1.PNG

@wwalser Also just tried to delete ":.+" inside the regex. Didn't help. 

Automation issue2.PNG

wwalser Atlassian Team Feb 15, 2021

There are number of points of fundamental confusion seeping into the discussion. I think there is some confusion about what case you're actually testing. In the OP there are two different conditions — one which checks the author and another which looks for user mention. Additionally there is confusion about when to check using equality against a specific value vs when to use a regular expression.

The regular expression that you are using from other threads on the community is for searching comment bodies for user mentions. The leading and trailing .* allows the regular expression to read past the other content in the body. The square bracket [~accountid:{id}] structure is the structure of a user mention.

The screenshot that you've just included seems to be attempting to check a comment author. In that case, you're checking against a smart value, where the ID will just be the identifier with no surrounding square brackets. If you need to check a comment author for a specific person, you don't need a regular expression, you can just use a standard equality check.

General debugging advice: Use the audit log action to print out he value that you're comparing. That will help in determining why the regular expression isn't matching.

Like Niklas Missel likes this

Thank you for breaking it down into small pieces. That helped me a lot.

You are absolutely right about me having trouble separating when to use regex and when not to :) 

We verified that it now works with the user - thank you for your help! 

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you