Can I input a JQL query into an automated comment?
Asked by Alexander Steel:

I am attempting to make a simple automated message when a ticket is triaged in Jira Servicedesk.

I want the message to say something like

"Hi {{issue.reporter.displayName}},

Your issue has been read over and assigned a priority of {{issue.priority.name}}.

We currently have X outstanding tickets of that priority or higher and are already working on Y of them.

We will pick your issue up as soon as we have cleared these tickets ahead of you in the queue.

Regards, the support team"

I can get JQL queries for the X and Y values fairly easily but can't find a way to enter it into the automated email.

Has anyone come across a way to do something similar?


Answers:
author: Semih Tolga Yazici
body: Hey Alexander,  

I will share with you a simple example to guide the solution that you can implement.  

X (All tickets that are not done) -\> {{issue.priority.name}} AND statusCategory != Done  
Y (In Progress) -\> {{issue.priority.name}} AND status = 'In Progress'  

Create an Automation.  
Select the trigger according to when you want to calculate the number of issues and send an email.  
Use branch rule (you can select current issue)  
LookupIssues action.  
And provide the JQL in there for X and Y.  
{{lookupIssues.size}} smart value will give you the number of issues.  
And you can add one more action which is Send email and use that smart value. Or you can put it into a customfield.  

However, there might be a total limit for the JQL that gets the issues.  

In that case, let's say the limit is 100.  

You can say in the email like there are more than 100 issues that are in the queue currently.  

<br />

The other but not the best way is counting the issues in a customfield. It will decrease the number -1 whenever and issue goes to the statusCategory = Done. It will increase the number whenever an issue is created.  

comments: author: Alexander Steel
body: I did see some similar comments but jira isn't happy with the {{lookupissues.size}} and is simply skipping over it.  
Is there some specific licence or versioning that is required?

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/348283i55BD5B50F9A61485/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/348284i62B0622C4DBC2574/image-size/large?v=v2&px=999 "image.png")


author: Alexander Steel
body: Strangely after trying again it worked, no change to any of the queries but it just seemed to work all of a sudden and since I have been able to test and it is working fine.

Thank you


author: Alexander Steel
body: The final section that allowed for the email![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/348297iD6BEB22CE08E3037/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/348298i987E3C6D710244E8/image-size/large?v=v2&px=999 "image.png")


author: Semih Tolga Yazici
body: I have just tried for you {{lookupIssues.size}} yeah it still works fine and it gave the result actually.

<br />

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/348343i436576D4557B3A08/image-size/large?v=v2&px=999 "image.png")

comments: author: Mark Higgins
body: Hi,

Yes, it now works for me as well? Weird.

I did add a log action inbetween but all is now good.

![Screenshot 2024-09-23 084708.png](https://community.atlassian.com/t5/image/serverpage/image-id/348618i61C5BF252CFCA20F/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 084708.png")

Email looks like:

![Screenshot 2024-09-23 084708.png](https://community.atlassian.com/t5/image/serverpage/image-id/348619i5AC7CB0572FE8988/image-size/large?v=v2&px=999 "Screenshot 2024-09-23 084708.png")

Thanks [@Alexander Steel](/t5/user/viewprofilepage/user-id/5597029) that is a very useful idea.

Mark


author: Mark Higgins
body: Hi [@Alexander Steel](/t5/user/viewprofilepage/user-id/5597029)

I was curious to see if this did work in my environment and it did not.

What did work (and I admit it's not ideal) is this:

{{#lookupIssues}}

\* {{key}}

{{/}}

which lists ALL the issues that the JQL returned.

Try as I might, I can not get the .size to work??

Mark


Tags: cloud

jira-automation

jira-service-management

jira-service-management-cloud