Check whether last comment author is not in a group
Asked by Tom De Blende:

Dear,

I want to execute an action in Jira Automation when a ticket is closed and the last comment is made by a user that is not part of an Atlassian group. I did some digging, and I'll probably need a condition based on {{comment.comment.last.author}}. However, I'm not quite sure how to verify its membership of a group. How can this be done?

If this would not be possible, how could I check whether the last comment was made by a customer user?

Thanks!  
Tom


Answers:
author: Tessa Tuteleers
body: Hi [@Tom De Blende](/t5/user/viewprofilepage/user-id/470349) ,

you could do this with a condition.

If the trigger is "Issue commented", you can use the user condition to check if the user who triggered the event is not in the default application user group.

-\> This works on the assumption that any user who does not have a license is a customer.

Hope this helps!

- Tessa

comments: author: Tom De Blende
body: Thanks Tessa. How does one check group membership in Jira Automation?


author: Tessa Tuteleers
body: Hi [@Tom De Blende](/t5/user/viewprofilepage/user-id/470349) ,

it's a specific kind of condition called "User condition", you can find it here:

![Screenshot 2023-04-20 at 13.16.16.png](https://community.atlassian.com/t5/image/serverpage/image-id/252925i462A641E033BDEFB/image-size/large?v=v2&px=999 "Screenshot 2023-04-20 at 13.16.16.png")

![Screenshot 2023-04-20 at 13.16.28.png](https://community.atlassian.com/t5/image/serverpage/image-id/252924i1F0A4582270AA5B7/image-size/large?v=v2&px=999 "Screenshot 2023-04-20 at 13.16.28.png")

Hope this helps!

- Tessa


author: Tom De Blende
body: It does and it doesn't :) Because I can't enter {{comment.comment.last.author}} in the User selection dropdown. One can only use a selection of criteria.

Is there to verify this?


author: Tom De Blende
body: Ideally something like this, but where the condition can be group membership:

![Clipboard01.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/253219i2EA1763B7A9B9BA3/image-size/large?v=v2&px=999 "Clipboard01.jpg")


author: Tessa Tuteleers
body: [@Tom De Blende](/t5/user/viewprofilepage/user-id/470349) ,

this would be ideal, but sadly it does not work because indeed there is way to compare this to group memberships.

That is why I propose to set the trigger as "Issue commented", then use not the "Advanced compare" but the "User condition", use "User who triggered the event" and then you can compare group membership.

This will only work if you use "Issue commented" as trigger, but working with the limitations of Automation for Jira, it's the only way I know how to solve this.

- Tessa


author: Tom De Blende
body: Yes, I understand. Unfortunately, this is not fit for the use case. I want to be notified when a ticket is (automatically) closed and the last comment was made by a customer. The trigger Issue Commented is not useful.

Thanks for thinking along!


author: Tessa Tuteleers
body: Ah, that's too bad.

Maybe there are other options that I'm not aware of (the suggestion given by [@David Pezet](/t5/user/viewprofilepage/user-id/4480447) for example) but,   
If this is really a "Must have" requirement, you could think about setting up a seperate rule as I described with the trigger "Issue commented", but instead of doing the action you need right then, use the rule to set a flag on your issue (i.e. use a custom field e.g. "Last commented by customer") that you check or uncheck with every comment based on if it was a customer or not.   
Then you can use your rule (trigger = transitioned to closed), and check whether or not the field is checked at that point in time.

Not the cleanest way to do it, but it would work.

- Tessa


author: Tom De Blende
body: This is how I ended up doing it, and it works as expected. Thanks for all the help ;)


author: David Pezet
body: You might try using a [Web Request](https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Send-web-request) ([additional article](https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828)) to [Get users from group](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-groups/#api-rest-api-3-group-member-get) and then compare if webResponse.body contains the last comment author. If you need to iterate through all the comments to find the last user comment (and not just the last comment) that would take a bit more wrangling.