Automation to check mailconnector
Asked by Evert Morren:

Some times our mailconnector fails. Therefore I tried to make two automation rules:

The first rule sends an email to the connector, with summary 'mailconnector check', this works.

The second rule must lookup if a ticket is created with the summary 'mailconnector check', if yes, the ticket must be deleted, if not then an email must be send to the admin.

How can I made a rule who is looking up for these specific ticket and if found it must be deleted.


Answers:
author: Evert Morren
body: Hi Bill, see below the details.

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

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

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

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

I have one ticket with the right description:

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

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

In this situation there won't be send an mail in my opinion.

After I deleted this ticket, the log file is:

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

Also in this situation a mail has been send. I don't understand what happens.

Regards.


author: Bill Sheboy
body: Hi [@Evert Morren](/t5/user/viewprofilepage/user-id/4476493)

That is an interesting use case to check for availability. Well done!

To find your issue to delete, consider how to make it unique-enough to find while being different from people-created issues.

For example, perhaps put something in the summary you can test with a condition, such as "mail connector TEST issue".

Kind regards,  
Bill

comments: author: Evert Morren C
body: Hi Bill, true, the summary must unique, but how can I search through the issue to find this specific issue?


author: Bill Sheboy
body: How many of these "canary" issues do you expect to exist at one time? If only one then:

* trigger: issue created
* condition: summary = "mail connector TEST issue"
* action: delete issue

I recommend using a longer and more unique summary to reduce the risks of problems.

If you expect there to be multiple, and you want to remove them at one time, consider instead using a scheduled trigger rule with the JQL to find them:

project = *myProjectName* AND summary = "mail connector TEST issue"


author: Evert Morren
body: Hi Bill,

The trigger "issue created" doesn't work, if the mail connector doesn't work there is no issue. The trigger must be sheduled. I made a sheduled rule but get the error message:

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

It seems not possible to trigger a scheduled rule without a JQL statement?


author: Bill Sheboy
body: Hi Evert,

Nope, you definitely can have a scheduled trigger rule without JQL.

And, are you using the Cloud or Server/Data Center version, as each has different batch processing options? For example for Cloud:

* trigger: scheduled on the cycle you select
* action: Lookup Issues with JQL replacing your project name and any other criteria

```
project = myProject 
AND summary = "mail connector TEST issue"
 AND ...any other criteria
```

* if/else condition: advanced compare condition: test for found issues with
  * first value: {{lookupIssues.size\|0}}
  * condition: greater than
  * second value: 0
    * action: delete issue
* else
  * action: send the email

This works for one-issue-found. If you possibly have more to delete, you will need a branch with the JQL before the delete action.


author: Evert Morren
body: Hi Bill, Thank you for reply.

I have made the rule you suggested, but still the same error.

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

It seems, it is not possible to do actions on an issue, without the option to run JQL?

I try it with two rules, the first one send a mail if these is no issue (mailconnector doesn't work), the second deletes the ticket if there is a ticket (mailconnector works). The first one doesn't work, what do I wrong?

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

Can you help me?


author: Bill Sheboy
body: Would you please post images of:

* the details of your Scheduled trigger, and
* of the audit log for a run where it does not work as you expect?

Thanks!


author: Evert Morren
body: Hi Bill, see below the details.

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

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

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

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

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

If I create a ticket with the right summary, the lookup find the issue, bu also a mail will be send.

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

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

I don't understand what happens?

Regards.


author: Bill Sheboy
body: Ah! Smart values are usually case sensitive, and unfortunately do not show errors when you get the case incorrect. The smart value for Lookup Issues uses camel-case:

```
{{lookupIssues.size|0}}
```

Please change your condition and see what happens.


author: Evert Morren
body: Hi Bill,

I have changed it, and it works now. Thank you very much for the support.

Regards,

Evert