JQL query for automation in Jira
Asked by George Davitaya:

Hi, their!

I am newbie in Automatisation Jira

I have a issue, I need to create a request for a JQL query for automation in Jira  
If there are tasks for approval, then send a message in Slack with a summary of tasks, if there are no tasks for approval, send a message "no tasks"

but when using the if function, I receive a message for each task, I think that the issue is in the request itself, how can I make the request correctly?

![1.png](https://community.atlassian.com/t5/image/serverpage/image-id/325621i7F755F19D6EC2139/image-size/large?v=v2&px=999 "1.png")![2.png](https://community.atlassian.com/t5/image/serverpage/image-id/325623i03E177BC6500E983/image-size/large?v=v2&px=999 "2.png")

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


Answers:
author: Fabian Lim
body: Hi [@George Davitaya](/t5/user/viewprofilepage/user-id/5504374)

Welcome to the community!

You need to ensure that the if and else statements are all within the same branch. In your automation, after the first if statement runs, then it will run the second and then the second one runs.

I hope this he.ps.


author: George Davitaya
body: Hi! [@Rudy Holtkamp](/t5/user/viewprofilepage/user-id/636802) [@Fabian Lim](/t5/user/viewprofilepage/user-id/3131564)

Do you mean it should be done this way? Sorry, I still don't understand well what you mean, can you give more information, because this way don't work(

Thanks in advance for your support

![4.png](https://community.atlassian.com/t5/image/serverpage/image-id/325873i68CEDA8862597B40/image-size/large?v=v2&px=999 "4.png")![5.png](https://community.atlassian.com/t5/image/serverpage/image-id/325874iB6710CDCEF350BC8/image-size/large?v=v2&px=999 "5.png")


author: Rudy Holtkamp
body: Hi [@George Davitaya](/t5/user/viewprofilepage/user-id/5504374) and welcome to the community,

In your trigger you are probably already looking for issues. And since you have three times the same output I assume that the trigger has three hits.

You should remove the JQL query in your trigger and place the lookup issue action as the next action with the JQL you removed from the trigger. After that you branch on smart value with {{lookupIssues}} as first value and lookupIssue as var.

Then you can use an if else condition with a smart value condition: {{lookupIssue.status.name}} equals Waiting for approval followed by the slack message. After that the else with another slack message (for all the issues that don't need an approval).

I hope this helps.

Rudy

comments: author: George Davitaya
body: Hi! [@Rudy Holtkamp](/t5/user/viewprofilepage/user-id/636802)

Do you mean it should be done this way? Sorry, I still don't understand well what you mean, can you give more information, thanks in advance for your support ![4.png](https://community.atlassian.com/t5/image/serverpage/image-id/325820iF8AE3E265D27A2B0/image-size/large?v=v2&px=999 "4.png")![5.png](https://community.atlassian.com/t5/image/serverpage/image-id/325821iFA03FE6D8B9E0F97/image-size/large?v=v2&px=999 "5.png")


Tags: cloud

jira-service-management

jira-service-management-cloud